@performant-software/geospatial 2.3.15-beta.6 → 2.3.15

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 (877) hide show
  1. package/dist/index.cjs100.js +1 -1
  2. package/dist/index.cjs100.js.map +1 -1
  3. package/dist/index.cjs101.js +1 -1
  4. package/dist/index.cjs101.js.map +1 -1
  5. package/dist/index.cjs102.js +1 -1
  6. package/dist/index.cjs102.js.map +1 -1
  7. package/dist/index.cjs103.js +1 -1
  8. package/dist/index.cjs103.js.map +1 -1
  9. package/dist/index.cjs104.js +1 -1
  10. package/dist/index.cjs104.js.map +1 -1
  11. package/dist/index.cjs105.js +1 -1
  12. package/dist/index.cjs105.js.map +1 -1
  13. package/dist/index.cjs106.js +1 -1
  14. package/dist/index.cjs106.js.map +1 -1
  15. package/dist/index.cjs107.js +1 -1
  16. package/dist/index.cjs107.js.map +1 -1
  17. package/dist/index.cjs108.js +1 -1
  18. package/dist/index.cjs108.js.map +1 -1
  19. package/dist/index.cjs109.js +1 -1
  20. package/dist/index.cjs109.js.map +1 -1
  21. package/dist/index.cjs110.js +1 -1
  22. package/dist/index.cjs110.js.map +1 -1
  23. package/dist/index.cjs111.js +1 -1
  24. package/dist/index.cjs111.js.map +1 -1
  25. package/dist/index.cjs112.js +1 -1
  26. package/dist/index.cjs112.js.map +1 -1
  27. package/dist/index.cjs113.js +1 -1
  28. package/dist/index.cjs113.js.map +1 -1
  29. package/dist/index.cjs114.js +1 -1
  30. package/dist/index.cjs114.js.map +1 -1
  31. package/dist/index.cjs115.js +1 -1
  32. package/dist/index.cjs115.js.map +1 -1
  33. package/dist/index.cjs116.js +1 -1
  34. package/dist/index.cjs116.js.map +1 -1
  35. package/dist/index.cjs117.js +1 -1
  36. package/dist/index.cjs117.js.map +1 -1
  37. package/dist/index.cjs118.js +1 -1
  38. package/dist/index.cjs118.js.map +1 -1
  39. package/dist/index.cjs119.js +1 -1
  40. package/dist/index.cjs119.js.map +1 -1
  41. package/dist/index.cjs12.js +1 -1
  42. package/dist/index.cjs120.js +1 -1
  43. package/dist/index.cjs120.js.map +1 -1
  44. package/dist/index.cjs121.js +1 -1
  45. package/dist/index.cjs121.js.map +1 -1
  46. package/dist/index.cjs122.js +1 -1
  47. package/dist/index.cjs122.js.map +1 -1
  48. package/dist/index.cjs123.js +1 -1
  49. package/dist/index.cjs123.js.map +1 -1
  50. package/dist/index.cjs124.js +1 -1
  51. package/dist/index.cjs124.js.map +1 -1
  52. package/dist/index.cjs125.js +1 -1
  53. package/dist/index.cjs125.js.map +1 -1
  54. package/dist/index.cjs126.js +1 -1
  55. package/dist/index.cjs126.js.map +1 -1
  56. package/dist/index.cjs127.js +1 -13
  57. package/dist/index.cjs127.js.map +1 -1
  58. package/dist/index.cjs128.js +1 -1
  59. package/dist/index.cjs128.js.map +1 -1
  60. package/dist/index.cjs129.js +13 -1
  61. package/dist/index.cjs129.js.map +1 -1
  62. package/dist/index.cjs130.js +1 -1
  63. package/dist/index.cjs130.js.map +1 -1
  64. package/dist/index.cjs131.js +1 -1
  65. package/dist/index.cjs131.js.map +1 -1
  66. package/dist/index.cjs132.js +1 -1
  67. package/dist/index.cjs132.js.map +1 -1
  68. package/dist/index.cjs133.js +1 -1
  69. package/dist/index.cjs133.js.map +1 -1
  70. package/dist/index.cjs134.js +1 -1
  71. package/dist/index.cjs134.js.map +1 -1
  72. package/dist/index.cjs135.js +1 -1
  73. package/dist/index.cjs135.js.map +1 -1
  74. package/dist/index.cjs136.js +1 -1
  75. package/dist/index.cjs136.js.map +1 -1
  76. package/dist/index.cjs137.js +1 -1
  77. package/dist/index.cjs137.js.map +1 -1
  78. package/dist/index.cjs138.js +1 -1
  79. package/dist/index.cjs138.js.map +1 -1
  80. package/dist/index.cjs139.js +1 -1
  81. package/dist/index.cjs139.js.map +1 -1
  82. package/dist/index.cjs14.js +1 -1
  83. package/dist/index.cjs140.js +1 -1
  84. package/dist/index.cjs140.js.map +1 -1
  85. package/dist/index.cjs141.js +1 -1
  86. package/dist/index.cjs141.js.map +1 -1
  87. package/dist/index.cjs142.js +1 -1
  88. package/dist/index.cjs142.js.map +1 -1
  89. package/dist/index.cjs143.js +1 -1
  90. package/dist/index.cjs143.js.map +1 -1
  91. package/dist/index.cjs144.js +1 -1
  92. package/dist/index.cjs144.js.map +1 -1
  93. package/dist/index.cjs145.js +1 -1
  94. package/dist/index.cjs145.js.map +1 -1
  95. package/dist/index.cjs146.js +1 -1
  96. package/dist/index.cjs146.js.map +1 -1
  97. package/dist/index.cjs147.js +1 -1
  98. package/dist/index.cjs147.js.map +1 -1
  99. package/dist/index.cjs148.js +1 -1
  100. package/dist/index.cjs148.js.map +1 -1
  101. package/dist/index.cjs149.js +1 -1
  102. package/dist/index.cjs149.js.map +1 -1
  103. package/dist/index.cjs15.js +1 -1
  104. package/dist/index.cjs15.js.map +1 -1
  105. package/dist/index.cjs150.js +1 -1
  106. package/dist/index.cjs150.js.map +1 -1
  107. package/dist/index.cjs151.js +1 -1
  108. package/dist/index.cjs151.js.map +1 -1
  109. package/dist/index.cjs152.js +1 -1
  110. package/dist/index.cjs152.js.map +1 -1
  111. package/dist/index.cjs153.js +1 -1
  112. package/dist/index.cjs153.js.map +1 -1
  113. package/dist/index.cjs154.js +1 -1
  114. package/dist/index.cjs154.js.map +1 -1
  115. package/dist/index.cjs155.js +1 -1
  116. package/dist/index.cjs155.js.map +1 -1
  117. package/dist/index.cjs156.js +1 -1
  118. package/dist/index.cjs156.js.map +1 -1
  119. package/dist/index.cjs157.js +1 -1
  120. package/dist/index.cjs157.js.map +1 -1
  121. package/dist/index.cjs158.js +1 -1
  122. package/dist/index.cjs158.js.map +1 -1
  123. package/dist/index.cjs159.js +1 -1
  124. package/dist/index.cjs159.js.map +1 -1
  125. package/dist/index.cjs16.js +1 -1
  126. package/dist/index.cjs160.js +1 -1
  127. package/dist/index.cjs160.js.map +1 -1
  128. package/dist/index.cjs161.js +1 -1
  129. package/dist/index.cjs161.js.map +1 -1
  130. package/dist/index.cjs162.js +1 -1
  131. package/dist/index.cjs162.js.map +1 -1
  132. package/dist/index.cjs163.js +1 -1
  133. package/dist/index.cjs163.js.map +1 -1
  134. package/dist/index.cjs164.js +1 -1
  135. package/dist/index.cjs164.js.map +1 -1
  136. package/dist/index.cjs165.js +1 -1
  137. package/dist/index.cjs165.js.map +1 -1
  138. package/dist/index.cjs166.js +1 -1
  139. package/dist/index.cjs166.js.map +1 -1
  140. package/dist/index.cjs167.js +1 -1
  141. package/dist/index.cjs167.js.map +1 -1
  142. package/dist/index.cjs168.js +1 -1
  143. package/dist/index.cjs168.js.map +1 -1
  144. package/dist/index.cjs169.js +1 -1
  145. package/dist/index.cjs169.js.map +1 -1
  146. package/dist/index.cjs17.js +1 -1
  147. package/dist/index.cjs170.js +1 -1
  148. package/dist/index.cjs170.js.map +1 -1
  149. package/dist/index.cjs171.js +1 -1
  150. package/dist/index.cjs171.js.map +1 -1
  151. package/dist/index.cjs172.js +1 -1
  152. package/dist/index.cjs172.js.map +1 -1
  153. package/dist/index.cjs173.js +1 -1
  154. package/dist/index.cjs173.js.map +1 -1
  155. package/dist/index.cjs174.js +1 -1
  156. package/dist/index.cjs174.js.map +1 -1
  157. package/dist/index.cjs175.js +1 -1
  158. package/dist/index.cjs175.js.map +1 -1
  159. package/dist/index.cjs176.js +1 -1
  160. package/dist/index.cjs176.js.map +1 -1
  161. package/dist/index.cjs177.js +1 -1
  162. package/dist/index.cjs177.js.map +1 -1
  163. package/dist/index.cjs178.js +1 -1
  164. package/dist/index.cjs178.js.map +1 -1
  165. package/dist/index.cjs179.js +1 -1
  166. package/dist/index.cjs179.js.map +1 -1
  167. package/dist/index.cjs180.js +1 -1
  168. package/dist/index.cjs180.js.map +1 -1
  169. package/dist/index.cjs181.js +1 -1
  170. package/dist/index.cjs181.js.map +1 -1
  171. package/dist/index.cjs182.js +1 -1
  172. package/dist/index.cjs182.js.map +1 -1
  173. package/dist/index.cjs183.js +1 -1
  174. package/dist/index.cjs183.js.map +1 -1
  175. package/dist/index.cjs184.js +1 -1
  176. package/dist/index.cjs184.js.map +1 -1
  177. package/dist/index.cjs185.js +1 -1
  178. package/dist/index.cjs185.js.map +1 -1
  179. package/dist/index.cjs186.js +1 -1
  180. package/dist/index.cjs186.js.map +1 -1
  181. package/dist/index.cjs187.js +1 -1
  182. package/dist/index.cjs187.js.map +1 -1
  183. package/dist/index.cjs188.js +1 -1
  184. package/dist/index.cjs188.js.map +1 -1
  185. package/dist/index.cjs189.js +1 -1
  186. package/dist/index.cjs189.js.map +1 -1
  187. package/dist/index.cjs19.js +1 -1
  188. package/dist/index.cjs190.js +1 -1
  189. package/dist/index.cjs190.js.map +1 -1
  190. package/dist/index.cjs191.js +1 -1
  191. package/dist/index.cjs194.js +1 -1
  192. package/dist/index.cjs195.js +1 -1
  193. package/dist/index.cjs196.js +1 -1
  194. package/dist/index.cjs197.js +1 -1
  195. package/dist/index.cjs198.js +1 -1
  196. package/dist/index.cjs199.js +1 -1
  197. package/dist/index.cjs200.js +1 -1
  198. package/dist/index.cjs201.js +1 -1
  199. package/dist/index.cjs203.js +1 -1
  200. package/dist/index.cjs204.js +1 -1
  201. package/dist/index.cjs206.js +1 -1
  202. package/dist/index.cjs206.js.map +1 -1
  203. package/dist/index.cjs207.js +1 -1
  204. package/dist/index.cjs207.js.map +1 -1
  205. package/dist/index.cjs208.js +1 -1
  206. package/dist/index.cjs208.js.map +1 -1
  207. package/dist/index.cjs209.js +1 -1
  208. package/dist/index.cjs209.js.map +1 -1
  209. package/dist/index.cjs21.js +1 -1
  210. package/dist/index.cjs210.js +1 -1
  211. package/dist/index.cjs210.js.map +1 -1
  212. package/dist/index.cjs211.js +1 -1
  213. package/dist/index.cjs211.js.map +1 -1
  214. package/dist/index.cjs212.js +1 -1
  215. package/dist/index.cjs212.js.map +1 -1
  216. package/dist/index.cjs213.js +1 -1
  217. package/dist/index.cjs213.js.map +1 -1
  218. package/dist/index.cjs214.js +1 -1
  219. package/dist/index.cjs214.js.map +1 -1
  220. package/dist/index.cjs215.js +1 -1
  221. package/dist/index.cjs215.js.map +1 -1
  222. package/dist/index.cjs216.js +1 -1
  223. package/dist/index.cjs216.js.map +1 -1
  224. package/dist/index.cjs217.js +1 -1
  225. package/dist/index.cjs217.js.map +1 -1
  226. package/dist/index.cjs218.js +1 -1
  227. package/dist/index.cjs218.js.map +1 -1
  228. package/dist/index.cjs219.js +1 -1
  229. package/dist/index.cjs219.js.map +1 -1
  230. package/dist/index.cjs22.js +1 -1
  231. package/dist/index.cjs220.js +1 -1
  232. package/dist/index.cjs220.js.map +1 -1
  233. package/dist/index.cjs221.js +1 -1
  234. package/dist/index.cjs221.js.map +1 -1
  235. package/dist/index.cjs222.js +1 -1
  236. package/dist/index.cjs222.js.map +1 -1
  237. package/dist/index.cjs223.js +1 -1
  238. package/dist/index.cjs223.js.map +1 -1
  239. package/dist/index.cjs224.js +1 -1
  240. package/dist/index.cjs224.js.map +1 -1
  241. package/dist/index.cjs225.js +1 -1
  242. package/dist/index.cjs225.js.map +1 -1
  243. package/dist/index.cjs226.js +1 -1
  244. package/dist/index.cjs226.js.map +1 -1
  245. package/dist/index.cjs227.js +1 -1
  246. package/dist/index.cjs227.js.map +1 -1
  247. package/dist/index.cjs228.js +1 -1
  248. package/dist/index.cjs228.js.map +1 -1
  249. package/dist/index.cjs229.js +1 -1
  250. package/dist/index.cjs229.js.map +1 -1
  251. package/dist/index.cjs23.js +1 -1
  252. package/dist/index.cjs230.js +1 -1
  253. package/dist/index.cjs230.js.map +1 -1
  254. package/dist/index.cjs231.js +1 -1
  255. package/dist/index.cjs231.js.map +1 -1
  256. package/dist/index.cjs232.js +1 -1
  257. package/dist/index.cjs232.js.map +1 -1
  258. package/dist/index.cjs233.js +1 -1
  259. package/dist/index.cjs233.js.map +1 -1
  260. package/dist/index.cjs234.js +1 -1
  261. package/dist/index.cjs234.js.map +1 -1
  262. package/dist/index.cjs235.js +1 -1
  263. package/dist/index.cjs235.js.map +1 -1
  264. package/dist/index.cjs236.js +1 -1
  265. package/dist/index.cjs236.js.map +1 -1
  266. package/dist/index.cjs237.js +1 -1
  267. package/dist/index.cjs237.js.map +1 -1
  268. package/dist/index.cjs238.js +1 -1
  269. package/dist/index.cjs238.js.map +1 -1
  270. package/dist/index.cjs239.js +1 -1
  271. package/dist/index.cjs239.js.map +1 -1
  272. package/dist/index.cjs240.js +1 -1
  273. package/dist/index.cjs240.js.map +1 -1
  274. package/dist/index.cjs241.js +1 -1
  275. package/dist/index.cjs241.js.map +1 -1
  276. package/dist/index.cjs242.js +1 -1
  277. package/dist/index.cjs242.js.map +1 -1
  278. package/dist/index.cjs243.js +1 -1
  279. package/dist/index.cjs243.js.map +1 -1
  280. package/dist/index.cjs244.js +1 -1
  281. package/dist/index.cjs244.js.map +1 -1
  282. package/dist/index.cjs245.js +1 -1
  283. package/dist/index.cjs245.js.map +1 -1
  284. package/dist/index.cjs246.js +1 -1
  285. package/dist/index.cjs246.js.map +1 -1
  286. package/dist/index.cjs247.js +1 -1
  287. package/dist/index.cjs247.js.map +1 -1
  288. package/dist/index.cjs248.js +1 -1
  289. package/dist/index.cjs248.js.map +1 -1
  290. package/dist/index.cjs249.js +1 -1
  291. package/dist/index.cjs249.js.map +1 -1
  292. package/dist/index.cjs25.js +1 -1
  293. package/dist/index.cjs250.js +1 -1
  294. package/dist/index.cjs250.js.map +1 -1
  295. package/dist/index.cjs251.js +1 -1
  296. package/dist/index.cjs251.js.map +1 -1
  297. package/dist/index.cjs252.js +1 -1
  298. package/dist/index.cjs252.js.map +1 -1
  299. package/dist/index.cjs253.js +1 -1
  300. package/dist/index.cjs253.js.map +1 -1
  301. package/dist/index.cjs254.js +1 -1
  302. package/dist/index.cjs254.js.map +1 -1
  303. package/dist/index.cjs255.js +1 -1
  304. package/dist/index.cjs255.js.map +1 -1
  305. package/dist/index.cjs256.js +1 -1
  306. package/dist/index.cjs256.js.map +1 -1
  307. package/dist/index.cjs257.js +1 -1
  308. package/dist/index.cjs257.js.map +1 -1
  309. package/dist/index.cjs258.js +1 -1
  310. package/dist/index.cjs259.js +1 -1
  311. package/dist/index.cjs259.js.map +1 -1
  312. package/dist/index.cjs26.js +1 -1
  313. package/dist/index.cjs260.js +1 -1
  314. package/dist/index.cjs260.js.map +1 -1
  315. package/dist/index.cjs261.js +1 -1
  316. package/dist/index.cjs261.js.map +1 -1
  317. package/dist/index.cjs27.js +1 -1
  318. package/dist/index.cjs29.js +1 -1
  319. package/dist/index.cjs30.js +1 -1
  320. package/dist/index.cjs31.js +1 -1
  321. package/dist/index.cjs32.js +1 -1
  322. package/dist/index.cjs33.js +1 -1
  323. package/dist/index.cjs34.js +1 -1
  324. package/dist/index.cjs35.js +1 -1
  325. package/dist/index.cjs37.js +1 -1
  326. package/dist/index.cjs38.js +1 -1
  327. package/dist/index.cjs39.js +1 -1
  328. package/dist/index.cjs40.js +1 -1
  329. package/dist/index.cjs42.js +1 -1
  330. package/dist/index.cjs43.js +1 -1
  331. package/dist/index.cjs44.js +1 -1
  332. package/dist/index.cjs45.js +1 -1
  333. package/dist/index.cjs46.js +1 -1
  334. package/dist/index.cjs47.js +1 -1
  335. package/dist/index.cjs48.js +1 -1
  336. package/dist/index.cjs49.js +1 -1
  337. package/dist/index.cjs5.js +1 -1
  338. package/dist/index.cjs5.js.map +1 -1
  339. package/dist/index.cjs50.js +1 -1
  340. package/dist/index.cjs52.js +1 -1
  341. package/dist/index.cjs54.js +1 -1
  342. package/dist/index.cjs54.js.map +1 -1
  343. package/dist/index.cjs55.js +440 -1
  344. package/dist/index.cjs55.js.map +1 -1
  345. package/dist/index.cjs56.js +1 -440
  346. package/dist/index.cjs56.js.map +1 -1
  347. package/dist/index.cjs57.js +1 -1
  348. package/dist/index.cjs57.js.map +1 -1
  349. package/dist/index.cjs58.js +1 -1
  350. package/dist/index.cjs58.js.map +1 -1
  351. package/dist/index.cjs59.js +1 -1
  352. package/dist/index.cjs59.js.map +1 -1
  353. package/dist/index.cjs60.js +9 -1
  354. package/dist/index.cjs60.js.map +1 -1
  355. package/dist/index.cjs61.js +13 -3
  356. package/dist/index.cjs61.js.map +1 -1
  357. package/dist/index.cjs62.js +1 -19
  358. package/dist/index.cjs62.js.map +1 -1
  359. package/dist/index.cjs63.js +1 -1
  360. package/dist/index.cjs63.js.map +1 -1
  361. package/dist/index.cjs64.js +1 -1
  362. package/dist/index.cjs64.js.map +1 -1
  363. package/dist/index.cjs65.js +1 -1
  364. package/dist/index.cjs65.js.map +1 -1
  365. package/dist/index.cjs67.js +1 -1
  366. package/dist/index.cjs67.js.map +1 -1
  367. package/dist/index.cjs68.js +1 -1
  368. package/dist/index.cjs68.js.map +1 -1
  369. package/dist/index.cjs69.js +1 -1
  370. package/dist/index.cjs69.js.map +1 -1
  371. package/dist/index.cjs70.js +1 -1
  372. package/dist/index.cjs70.js.map +1 -1
  373. package/dist/index.cjs71.js +1 -1
  374. package/dist/index.cjs71.js.map +1 -1
  375. package/dist/index.cjs72.js +1 -1
  376. package/dist/index.cjs72.js.map +1 -1
  377. package/dist/index.cjs73.js +1 -1
  378. package/dist/index.cjs73.js.map +1 -1
  379. package/dist/index.cjs74.js +1 -1
  380. package/dist/index.cjs74.js.map +1 -1
  381. package/dist/index.cjs75.js +1 -1
  382. package/dist/index.cjs75.js.map +1 -1
  383. package/dist/index.cjs76.js +1 -1
  384. package/dist/index.cjs76.js.map +1 -1
  385. package/dist/index.cjs78.js +1 -1
  386. package/dist/index.cjs78.js.map +1 -1
  387. package/dist/index.cjs79.js +1 -1
  388. package/dist/index.cjs79.js.map +1 -1
  389. package/dist/index.cjs8.js +1 -1
  390. package/dist/index.cjs8.js.map +1 -1
  391. package/dist/index.cjs80.js +1 -1
  392. package/dist/index.cjs80.js.map +1 -1
  393. package/dist/index.cjs81.js +1 -1
  394. package/dist/index.cjs81.js.map +1 -1
  395. package/dist/index.cjs82.js +1 -1
  396. package/dist/index.cjs82.js.map +1 -1
  397. package/dist/index.cjs83.js +1 -1
  398. package/dist/index.cjs83.js.map +1 -1
  399. package/dist/index.cjs84.js +1 -1
  400. package/dist/index.cjs84.js.map +1 -1
  401. package/dist/index.cjs85.js +1 -1
  402. package/dist/index.cjs85.js.map +1 -1
  403. package/dist/index.cjs86.js +1 -1
  404. package/dist/index.cjs86.js.map +1 -1
  405. package/dist/index.cjs87.js +1 -1
  406. package/dist/index.cjs87.js.map +1 -1
  407. package/dist/index.cjs88.js +1 -1
  408. package/dist/index.cjs88.js.map +1 -1
  409. package/dist/index.cjs89.js +1 -1
  410. package/dist/index.cjs89.js.map +1 -1
  411. package/dist/index.cjs90.js +1 -1
  412. package/dist/index.cjs90.js.map +1 -1
  413. package/dist/index.cjs91.js +1 -1
  414. package/dist/index.cjs91.js.map +1 -1
  415. package/dist/index.cjs92.js +1 -1
  416. package/dist/index.cjs92.js.map +1 -1
  417. package/dist/index.cjs93.js +1 -1
  418. package/dist/index.cjs93.js.map +1 -1
  419. package/dist/index.cjs94.js +1 -1
  420. package/dist/index.cjs94.js.map +1 -1
  421. package/dist/index.cjs95.js +1 -1
  422. package/dist/index.cjs95.js.map +1 -1
  423. package/dist/index.cjs96.js +1 -1
  424. package/dist/index.cjs96.js.map +1 -1
  425. package/dist/index.cjs97.js +1 -1
  426. package/dist/index.cjs97.js.map +1 -1
  427. package/dist/index.cjs98.js +1 -1
  428. package/dist/index.cjs98.js.map +1 -1
  429. package/dist/index.cjs99.js +1 -1
  430. package/dist/index.cjs99.js.map +1 -1
  431. package/dist/index.es100.js +9 -12
  432. package/dist/index.es100.js.map +1 -1
  433. package/dist/index.es101.js +11 -85
  434. package/dist/index.es101.js.map +1 -1
  435. package/dist/index.es102.js +13 -3
  436. package/dist/index.es102.js.map +1 -1
  437. package/dist/index.es103.js +85 -14
  438. package/dist/index.es103.js.map +1 -1
  439. package/dist/index.es104.js +3 -12
  440. package/dist/index.es104.js.map +1 -1
  441. package/dist/index.es105.js +14 -6
  442. package/dist/index.es105.js.map +1 -1
  443. package/dist/index.es106.js +11 -6
  444. package/dist/index.es106.js.map +1 -1
  445. package/dist/index.es107.js +5 -5
  446. package/dist/index.es107.js.map +1 -1
  447. package/dist/index.es108.js +6 -7
  448. package/dist/index.es108.js.map +1 -1
  449. package/dist/index.es109.js +6 -3
  450. package/dist/index.es109.js.map +1 -1
  451. package/dist/index.es110.js +8 -4
  452. package/dist/index.es110.js.map +1 -1
  453. package/dist/index.es111.js +3 -3
  454. package/dist/index.es111.js.map +1 -1
  455. package/dist/index.es112.js +4 -7
  456. package/dist/index.es112.js.map +1 -1
  457. package/dist/index.es113.js +4 -7
  458. package/dist/index.es113.js.map +1 -1
  459. package/dist/index.es114.js +6 -3
  460. package/dist/index.es114.js.map +1 -1
  461. package/dist/index.es115.js +6 -7
  462. package/dist/index.es115.js.map +1 -1
  463. package/dist/index.es116.js +3 -12
  464. package/dist/index.es116.js.map +1 -1
  465. package/dist/index.es117.js +7 -10
  466. package/dist/index.es117.js.map +1 -1
  467. package/dist/index.es118.js +12 -3
  468. package/dist/index.es118.js.map +1 -1
  469. package/dist/index.es119.js +10 -5
  470. package/dist/index.es119.js.map +1 -1
  471. package/dist/index.es12.js +4 -4
  472. package/dist/index.es120.js +3 -2
  473. package/dist/index.es120.js.map +1 -1
  474. package/dist/index.es121.js +4 -6
  475. package/dist/index.es121.js.map +1 -1
  476. package/dist/index.es122.js +2 -7
  477. package/dist/index.es122.js.map +1 -1
  478. package/dist/index.es123.js +6 -6
  479. package/dist/index.es123.js.map +1 -1
  480. package/dist/index.es124.js +7 -8
  481. package/dist/index.es124.js.map +1 -1
  482. package/dist/index.es125.js +7 -3
  483. package/dist/index.es125.js.map +1 -1
  484. package/dist/index.es126.js +9 -4
  485. package/dist/index.es126.js.map +1 -1
  486. package/dist/index.es127.js +3 -57
  487. package/dist/index.es127.js.map +1 -1
  488. package/dist/index.es128.js +4 -14
  489. package/dist/index.es128.js.map +1 -1
  490. package/dist/index.es129.js +57 -5
  491. package/dist/index.es129.js.map +1 -1
  492. package/dist/index.es130.js +13 -5
  493. package/dist/index.es130.js.map +1 -1
  494. package/dist/index.es131.js +5 -8
  495. package/dist/index.es131.js.map +1 -1
  496. package/dist/index.es132.js +5 -16
  497. package/dist/index.es132.js.map +1 -1
  498. package/dist/index.es133.js +8 -13
  499. package/dist/index.es133.js.map +1 -1
  500. package/dist/index.es134.js +16 -4
  501. package/dist/index.es134.js.map +1 -1
  502. package/dist/index.es135.js +13 -5
  503. package/dist/index.es135.js.map +1 -1
  504. package/dist/index.es136.js +4 -8
  505. package/dist/index.es136.js.map +1 -1
  506. package/dist/index.es137.js +3 -4
  507. package/dist/index.es137.js.map +1 -1
  508. package/dist/index.es138.js +6 -4
  509. package/dist/index.es138.js.map +1 -1
  510. package/dist/index.es139.js +6 -8
  511. package/dist/index.es139.js.map +1 -1
  512. package/dist/index.es14.js +2 -2
  513. package/dist/index.es140.js +7 -3
  514. package/dist/index.es140.js.map +1 -1
  515. package/dist/index.es141.js +9 -3
  516. package/dist/index.es141.js.map +1 -1
  517. package/dist/index.es142.js +3 -11
  518. package/dist/index.es142.js.map +1 -1
  519. package/dist/index.es143.js +3 -5
  520. package/dist/index.es143.js.map +1 -1
  521. package/dist/index.es144.js +11 -4
  522. package/dist/index.es144.js.map +1 -1
  523. package/dist/index.es145.js +5 -9
  524. package/dist/index.es145.js.map +1 -1
  525. package/dist/index.es146.js +4 -6
  526. package/dist/index.es146.js.map +1 -1
  527. package/dist/index.es147.js +8 -16
  528. package/dist/index.es147.js.map +1 -1
  529. package/dist/index.es148.js +5 -11
  530. package/dist/index.es148.js.map +1 -1
  531. package/dist/index.es149.js +17 -3
  532. package/dist/index.es149.js.map +1 -1
  533. package/dist/index.es15.js +8 -8
  534. package/dist/index.es15.js.map +1 -1
  535. package/dist/index.es150.js +12 -3
  536. package/dist/index.es150.js.map +1 -1
  537. package/dist/index.es151.js +3 -9
  538. package/dist/index.es151.js.map +1 -1
  539. package/dist/index.es152.js +3 -7
  540. package/dist/index.es152.js.map +1 -1
  541. package/dist/index.es153.js +8 -12
  542. package/dist/index.es153.js.map +1 -1
  543. package/dist/index.es154.js +6 -12
  544. package/dist/index.es154.js.map +1 -1
  545. package/dist/index.es155.js +12 -6
  546. package/dist/index.es155.js.map +1 -1
  547. package/dist/index.es156.js +12 -5
  548. package/dist/index.es156.js.map +1 -1
  549. package/dist/index.es157.js +6 -5
  550. package/dist/index.es157.js.map +1 -1
  551. package/dist/index.es158.js +5 -16
  552. package/dist/index.es158.js.map +1 -1
  553. package/dist/index.es159.js +5 -16
  554. package/dist/index.es159.js.map +1 -1
  555. package/dist/index.es16.js +1 -1
  556. package/dist/index.es160.js +16 -4
  557. package/dist/index.es160.js.map +1 -1
  558. package/dist/index.es161.js +16 -16
  559. package/dist/index.es161.js.map +1 -1
  560. package/dist/index.es162.js +4 -22
  561. package/dist/index.es162.js.map +1 -1
  562. package/dist/index.es163.js +17 -6
  563. package/dist/index.es163.js.map +1 -1
  564. package/dist/index.es164.js +23 -5
  565. package/dist/index.es164.js.map +1 -1
  566. package/dist/index.es165.js +5 -5
  567. package/dist/index.es165.js.map +1 -1
  568. package/dist/index.es166.js +5 -5
  569. package/dist/index.es166.js.map +1 -1
  570. package/dist/index.es167.js +6 -12
  571. package/dist/index.es167.js.map +1 -1
  572. package/dist/index.es168.js +5 -6
  573. package/dist/index.es168.js.map +1 -1
  574. package/dist/index.es169.js +11 -4
  575. package/dist/index.es169.js.map +1 -1
  576. package/dist/index.es17.js +3 -3
  577. package/dist/index.es170.js +5 -4
  578. package/dist/index.es170.js.map +1 -1
  579. package/dist/index.es171.js +3 -3
  580. package/dist/index.es171.js.map +1 -1
  581. package/dist/index.es172.js +3 -3
  582. package/dist/index.es172.js.map +1 -1
  583. package/dist/index.es173.js +4 -4
  584. package/dist/index.es173.js.map +1 -1
  585. package/dist/index.es174.js +4 -4
  586. package/dist/index.es174.js.map +1 -1
  587. package/dist/index.es175.js +4 -12
  588. package/dist/index.es175.js.map +1 -1
  589. package/dist/index.es176.js +4 -14
  590. package/dist/index.es176.js.map +1 -1
  591. package/dist/index.es177.js +12 -8
  592. package/dist/index.es177.js.map +1 -1
  593. package/dist/index.es178.js +14 -6
  594. package/dist/index.es178.js.map +1 -1
  595. package/dist/index.es179.js +8 -6
  596. package/dist/index.es179.js.map +1 -1
  597. package/dist/index.es180.js +6 -8
  598. package/dist/index.es180.js.map +1 -1
  599. package/dist/index.es181.js +6 -27
  600. package/dist/index.es181.js.map +1 -1
  601. package/dist/index.es182.js +8 -50
  602. package/dist/index.es182.js.map +1 -1
  603. package/dist/index.es183.js +316 -60
  604. package/dist/index.es183.js.map +1 -1
  605. package/dist/index.es184.js +71 -317
  606. package/dist/index.es184.js.map +1 -1
  607. package/dist/index.es185.js +3 -75
  608. package/dist/index.es185.js.map +1 -1
  609. package/dist/index.es186.js +16 -3
  610. package/dist/index.es186.js.map +1 -1
  611. package/dist/index.es187.js +10 -15
  612. package/dist/index.es187.js.map +1 -1
  613. package/dist/index.es188.js +29 -9
  614. package/dist/index.es188.js.map +1 -1
  615. package/dist/index.es189.js +4 -30
  616. package/dist/index.es189.js.map +1 -1
  617. package/dist/index.es19.js +2 -2
  618. package/dist/index.es190.js +2 -5
  619. package/dist/index.es190.js.map +1 -1
  620. package/dist/index.es191.js +2 -2
  621. package/dist/index.es194.js +1 -1
  622. package/dist/index.es195.js +1 -1
  623. package/dist/index.es196.js +2 -2
  624. package/dist/index.es197.js +2 -2
  625. package/dist/index.es198.js +3 -3
  626. package/dist/index.es199.js +1 -1
  627. package/dist/index.es200.js +1 -1
  628. package/dist/index.es201.js +1 -1
  629. package/dist/index.es203.js +2 -2
  630. package/dist/index.es204.js +3 -3
  631. package/dist/index.es206.js +8 -2
  632. package/dist/index.es206.js.map +1 -1
  633. package/dist/index.es207.js +4 -45
  634. package/dist/index.es207.js.map +1 -1
  635. package/dist/index.es208.js +4 -23
  636. package/dist/index.es208.js.map +1 -1
  637. package/dist/index.es209.js +3 -8
  638. package/dist/index.es209.js.map +1 -1
  639. package/dist/index.es21.js +2 -2
  640. package/dist/index.es210.js +3 -5
  641. package/dist/index.es210.js.map +1 -1
  642. package/dist/index.es211.js +9 -4
  643. package/dist/index.es211.js.map +1 -1
  644. package/dist/index.es212.js +22 -3
  645. package/dist/index.es212.js.map +1 -1
  646. package/dist/index.es213.js +22 -3
  647. package/dist/index.es213.js.map +1 -1
  648. package/dist/index.es214.js +13 -8
  649. package/dist/index.es214.js.map +1 -1
  650. package/dist/index.es215.js +15 -20
  651. package/dist/index.es215.js.map +1 -1
  652. package/dist/index.es216.js +5 -21
  653. package/dist/index.es216.js.map +1 -1
  654. package/dist/index.es217.js +8 -13
  655. package/dist/index.es217.js.map +1 -1
  656. package/dist/index.es218.js +6 -16
  657. package/dist/index.es218.js.map +1 -1
  658. package/dist/index.es219.js +21 -5
  659. package/dist/index.es219.js.map +1 -1
  660. package/dist/index.es22.js +2 -2
  661. package/dist/index.es220.js +9 -8
  662. package/dist/index.es220.js.map +1 -1
  663. package/dist/index.es221.js +9 -7
  664. package/dist/index.es221.js.map +1 -1
  665. package/dist/index.es222.js +4 -22
  666. package/dist/index.es222.js.map +1 -1
  667. package/dist/index.es223.js +10 -9
  668. package/dist/index.es223.js.map +1 -1
  669. package/dist/index.es224.js +9 -9
  670. package/dist/index.es224.js.map +1 -1
  671. package/dist/index.es225.js +23 -4
  672. package/dist/index.es225.js.map +1 -1
  673. package/dist/index.es226.js +11 -10
  674. package/dist/index.es226.js.map +1 -1
  675. package/dist/index.es227.js +18 -8
  676. package/dist/index.es227.js.map +1 -1
  677. package/dist/index.es228.js +4 -23
  678. package/dist/index.es228.js.map +1 -1
  679. package/dist/index.es229.js +16 -10
  680. package/dist/index.es229.js.map +1 -1
  681. package/dist/index.es23.js +2 -2
  682. package/dist/index.es230.js +10 -17
  683. package/dist/index.es230.js.map +1 -1
  684. package/dist/index.es231.js +4 -4
  685. package/dist/index.es231.js.map +1 -1
  686. package/dist/index.es232.js +4 -17
  687. package/dist/index.es232.js.map +1 -1
  688. package/dist/index.es233.js +44 -10
  689. package/dist/index.es233.js.map +1 -1
  690. package/dist/index.es234.js +22 -3
  691. package/dist/index.es234.js.map +1 -1
  692. package/dist/index.es235.js +3 -5
  693. package/dist/index.es235.js.map +1 -1
  694. package/dist/index.es236.js +6 -3
  695. package/dist/index.es236.js.map +1 -1
  696. package/dist/index.es237.js +6 -4
  697. package/dist/index.es237.js.map +1 -1
  698. package/dist/index.es238.js +24 -7
  699. package/dist/index.es238.js.map +1 -1
  700. package/dist/index.es239.js +15 -23
  701. package/dist/index.es239.js.map +1 -1
  702. package/dist/index.es240.js +29 -15
  703. package/dist/index.es240.js.map +1 -1
  704. package/dist/index.es241.js +20 -29
  705. package/dist/index.es241.js.map +1 -1
  706. package/dist/index.es242.js +75 -21
  707. package/dist/index.es242.js.map +1 -1
  708. package/dist/index.es243.js +18 -73
  709. package/dist/index.es243.js.map +1 -1
  710. package/dist/index.es244.js +47 -19
  711. package/dist/index.es244.js.map +1 -1
  712. package/dist/index.es245.js +48 -42
  713. package/dist/index.es245.js.map +1 -1
  714. package/dist/index.es246.js +8 -54
  715. package/dist/index.es246.js.map +1 -1
  716. package/dist/index.es247.js +20 -8
  717. package/dist/index.es247.js.map +1 -1
  718. package/dist/index.es248.js +63 -18
  719. package/dist/index.es248.js.map +1 -1
  720. package/dist/index.es249.js +41 -64
  721. package/dist/index.es249.js.map +1 -1
  722. package/dist/index.es25.js +1 -1
  723. package/dist/index.es250.js +64 -41
  724. package/dist/index.es250.js.map +1 -1
  725. package/dist/index.es251.js +7 -64
  726. package/dist/index.es251.js.map +1 -1
  727. package/dist/index.es252.js +3 -8
  728. package/dist/index.es252.js.map +1 -1
  729. package/dist/index.es253.js +12 -3
  730. package/dist/index.es253.js.map +1 -1
  731. package/dist/index.es254.js +58 -11
  732. package/dist/index.es254.js.map +1 -1
  733. package/dist/index.es255.js +54 -57
  734. package/dist/index.es255.js.map +1 -1
  735. package/dist/index.es256.js +2 -56
  736. package/dist/index.es256.js.map +1 -1
  737. package/dist/index.es257.js +15 -2
  738. package/dist/index.es257.js.map +1 -1
  739. package/dist/index.es258.js +1 -1
  740. package/dist/index.es259.js +70 -15
  741. package/dist/index.es259.js.map +1 -1
  742. package/dist/index.es26.js +1 -1
  743. package/dist/index.es260.js +3 -70
  744. package/dist/index.es260.js.map +1 -1
  745. package/dist/index.es261.js +24 -3
  746. package/dist/index.es261.js.map +1 -1
  747. package/dist/index.es27.js +2 -2
  748. package/dist/index.es29.js +2 -2
  749. package/dist/index.es30.js +2 -2
  750. package/dist/index.es31.js +2 -2
  751. package/dist/index.es32.js +1 -1
  752. package/dist/index.es33.js +1 -1
  753. package/dist/index.es34.js +2 -2
  754. package/dist/index.es35.js +2 -2
  755. package/dist/index.es37.js +2 -2
  756. package/dist/index.es38.js +2 -2
  757. package/dist/index.es39.js +2 -2
  758. package/dist/index.es40.js +1 -1
  759. package/dist/index.es42.js +1 -1
  760. package/dist/index.es43.js +4 -4
  761. package/dist/index.es44.js +5 -5
  762. package/dist/index.es45.js +5 -5
  763. package/dist/index.es46.js +1 -1
  764. package/dist/index.es47.js +3 -3
  765. package/dist/index.es48.js +4 -4
  766. package/dist/index.es49.js +2 -2
  767. package/dist/index.es5.js +7 -7
  768. package/dist/index.es5.js.map +1 -1
  769. package/dist/index.es50.js +2 -2
  770. package/dist/index.es52.js +4 -4
  771. package/dist/index.es54.js +86 -1
  772. package/dist/index.es54.js.map +1 -1
  773. package/dist/index.es55.js +13817 -71
  774. package/dist/index.es55.js.map +1 -1
  775. package/dist/index.es56.js +9 -13830
  776. package/dist/index.es56.js.map +1 -1
  777. package/dist/index.es57.js +9 -8
  778. package/dist/index.es57.js.map +1 -1
  779. package/dist/index.es58.js +84 -9
  780. package/dist/index.es58.js.map +1 -1
  781. package/dist/index.es59.js +2 -85
  782. package/dist/index.es59.js.map +1 -1
  783. package/dist/index.es60.js +30 -2
  784. package/dist/index.es60.js.map +1 -1
  785. package/dist/index.es61.js +593 -21
  786. package/dist/index.es61.js.map +1 -1
  787. package/dist/index.es62.js +5 -601
  788. package/dist/index.es62.js.map +1 -1
  789. package/dist/index.es63.js +2 -107
  790. package/dist/index.es63.js.map +1 -1
  791. package/dist/index.es64.js +107 -10
  792. package/dist/index.es64.js.map +1 -1
  793. package/dist/index.es65.js +10 -6
  794. package/dist/index.es65.js.map +1 -1
  795. package/dist/index.es66.js +2 -2
  796. package/dist/index.es67.js +55 -2
  797. package/dist/index.es67.js.map +1 -1
  798. package/dist/index.es68.js +47 -56
  799. package/dist/index.es68.js.map +1 -1
  800. package/dist/index.es69.js +37 -46
  801. package/dist/index.es69.js.map +1 -1
  802. package/dist/index.es70.js +11 -38
  803. package/dist/index.es70.js.map +1 -1
  804. package/dist/index.es71.js +13 -10
  805. package/dist/index.es71.js.map +1 -1
  806. package/dist/index.es72.js +29 -14
  807. package/dist/index.es72.js.map +1 -1
  808. package/dist/index.es73.js +14 -29
  809. package/dist/index.es73.js.map +1 -1
  810. package/dist/index.es74.js +12 -13
  811. package/dist/index.es74.js.map +1 -1
  812. package/dist/index.es75.js +12 -13
  813. package/dist/index.es75.js.map +1 -1
  814. package/dist/index.es76.js +2 -11
  815. package/dist/index.es76.js.map +1 -1
  816. package/dist/index.es77.js +2 -2
  817. package/dist/index.es78.js +28 -2
  818. package/dist/index.es78.js.map +1 -1
  819. package/dist/index.es79.js +51 -273
  820. package/dist/index.es79.js.map +1 -1
  821. package/dist/index.es8.js +11 -12
  822. package/dist/index.es8.js.map +1 -1
  823. package/dist/index.es80.js +64 -14
  824. package/dist/index.es80.js.map +1 -1
  825. package/dist/index.es81.js +273 -19
  826. package/dist/index.es81.js.map +1 -1
  827. package/dist/index.es82.js +14 -4
  828. package/dist/index.es82.js.map +1 -1
  829. package/dist/index.es83.js +18 -3
  830. package/dist/index.es83.js.map +1 -1
  831. package/dist/index.es84.js +3 -2
  832. package/dist/index.es84.js.map +1 -1
  833. package/dist/index.es85.js +3 -4
  834. package/dist/index.es85.js.map +1 -1
  835. package/dist/index.es86.js +1 -1
  836. package/dist/index.es86.js.map +1 -1
  837. package/dist/index.es87.js +5 -3
  838. package/dist/index.es87.js.map +1 -1
  839. package/dist/index.es88.js +4 -3
  840. package/dist/index.es88.js.map +1 -1
  841. package/dist/index.es89.js +3 -3
  842. package/dist/index.es89.js.map +1 -1
  843. package/dist/index.es90.js +3 -3
  844. package/dist/index.es90.js.map +1 -1
  845. package/dist/index.es91.js +3 -3
  846. package/dist/index.es91.js.map +1 -1
  847. package/dist/index.es92.js +3 -3
  848. package/dist/index.es92.js.map +1 -1
  849. package/dist/index.es93.js +3 -3
  850. package/dist/index.es93.js.map +1 -1
  851. package/dist/index.es94.js +3 -10
  852. package/dist/index.es94.js.map +1 -1
  853. package/dist/index.es95.js +3 -4
  854. package/dist/index.es95.js.map +1 -1
  855. package/dist/index.es96.js +9 -5
  856. package/dist/index.es96.js.map +1 -1
  857. package/dist/index.es97.js +4 -6
  858. package/dist/index.es97.js.map +1 -1
  859. package/dist/index.es98.js +5 -9
  860. package/dist/index.es98.js.map +1 -1
  861. package/dist/index.es99.js +5 -11
  862. package/dist/index.es99.js.map +1 -1
  863. package/dist/style.css +1 -1
  864. package/package.json +1 -1
  865. package/src/components/LayerMenu.js +1 -2
  866. package/src/components/MapDraw.css +1 -0
  867. package/src/components/MapDraw.js +0 -2
  868. package/types/components/LayerMenu.js.flow +1 -2
  869. package/types/components/MapDraw.js.flow +0 -2
  870. package/build/index.js +0 -2
  871. package/build/index.js.map +0 -1
  872. package/build/main.css +0 -127
  873. package/dist/index.cjs262.js +0 -2
  874. package/dist/index.cjs262.js.map +0 -1
  875. package/dist/index.es262.js +0 -28
  876. package/dist/index.es262.js.map +0 -1
  877. package/types/components/LocationMarker.js.flow +0 -82
@@ -1,2 +1,441 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var i=63710088e-1,l={centimeters:i*100,centimetres:i*100,degrees:i/111325,feet:i*3.28084,inches:i*39.37,kilometers:i/1e3,kilometres:i/1e3,meters:i,metres:i,miles:i/1609.344,millimeters:i*1e3,millimetres:i*1e3,nauticalmiles:i/1852,radians:1,yards:i*1.0936};function u(t,r,e){e===void 0&&(e={});var a={type:"Feature"};return(e.id===0||e.id)&&(a.id=e.id),e.bbox&&(a.bbox=e.bbox),a.properties=r||{},a.geometry=t,a}function m(t,r,e){if(e===void 0&&(e={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!f(t[0])||!f(t[1]))throw new Error("coordinates must contain numbers");var a={type:"Point",coordinates:t};return u(a,r,e)}function h(t,r,e){e===void 0&&(e={});for(var a=0,s=t;a<s.length;a++){var o=s[a];if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var n=0;n<o[o.length-1].length;n++)if(o[o.length-1][n]!==o[0][n])throw new Error("First and last Position are not equivalent.")}var d={type:"Polygon",coordinates:t};return u(d,r,e)}function v(t,r){r===void 0&&(r={});var e={type:"FeatureCollection"};return r.id&&(e.id=r.id),r.bbox&&(e.bbox=r.bbox),e.features=t,e}function b(t,r){r===void 0&&(r="kilometers");var e=l[r];if(!e)throw new Error(r+" units is invalid");return t*e}function c(t,r){r===void 0&&(r="kilometers");var e=l[r];if(!e)throw new Error(r+" units is invalid");return t/e}function f(t){return!isNaN(t)&&t!==null&&!Array.isArray(t)}exports.earthRadius=i;exports.factors=l;exports.feature=u;exports.featureCollection=v;exports.isNumber=f;exports.lengthToRadians=c;exports.point=m;exports.polygon=h;exports.radiansToLength=b;
1
+ "use strict";var ea=Object.defineProperty;var ra=(i,e,t)=>e in i?ea(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var M=(i,e,t)=>(ra(i,typeof e!="symbol"?e+"":e,t),t),vi=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var Rt=(i,e,t)=>(vi(i,e,"read from private field"),t?t.call(i):e.get(i)),wi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},cr=(i,e,t,r)=>(vi(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t);var xi=(i,e,t)=>(vi(i,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function we(i,e){const t=e[0],r=e[1];return[i[0]*t+i[2]*r+i[4],i[1]*t+i[3]*r+i[5]]}function ia(){return[1,0,0,1,0,0]}function sa(i,e){const t=i[0],r=i[1],s=i[2],n=i[3],o=i[4],a=i[5],h=e[0],c=e[1],l=e[2],u=e[3],m=e[4],g=e[5];return[t*h+s*c,r*h+n*c,t*l+s*u,r*l+n*u,t*m+s*g+o,r*m+n*g+a]}function Es(i,e,t,r,s,n,o){const a=Math.sin(s),h=Math.cos(s);return[t*h,r*a,-t*a,r*h,n*t*h-o*t*a+i,n*r*a+o*r*h+e]}function na(i){const e=oa(i),t=i[0],r=i[1],s=i[2],n=i[3],o=i[4],a=i[5];return[n/e,-r/e,-s/e,t/e,(s*a-n*o)/e,-(t*a-r*o)/e]}function oa(i){return i[0]*i[3]-i[1]*i[2]}function aa(i){const e=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return e[0]=i[0],e[1]=i[1],e[4]=i[2],e[5]=i[3],e[12]=i[4],e[13]=i[5],e}async function ln(i,e,t){let r;if(typeof t=="function"?r=await t(i,e):r=await fetch(i,e),!r.ok)throw new Error(r.statusText);return r}async function ha(i,e,t){return await(await ln(i,e,t)).json()}async function ca(i,e,t){return await ha(`${i}/info.json`,e,t)}function un(i,e=!1){switch(i.type){case"Polygon":return i.coordinates?{...i,coordinates:_s(i.coordinates,e)}:i;case"MultiPolygon":return i.coordinates?{...i,coordinates:i.coordinates.map(t=>_s(t,e))}:i;case"GeometryCollection":return{...i,geometries:i.geometries.map(t=>un(t,e))};default:return i}}function _s(i,e){if(i.length===0)return i;const t=[];for(let r=0;r<i.length;r++)t.push(la(i[r],r===0?e:!e));return t}function la(i,e){let t=0,r=0;for(let s=0,n=i.length,o=n-1;s<n;o=s++){const a=(i[s][0]-i[o][0])*(i[o][1]+i[s][1]),h=t+a;r+=Math.abs(t)>=Math.abs(a)?t-h+a:a-h+t,t=h}return t+r>=0!=!!e?i.slice().reverse():i}function gt(i){return Array.isArray(i)&&i.length===2&&typeof i[0]=="number"&&typeof i[1]=="number"}function St(i){return Array.isArray(i)&&i.every(gt)}function ua(i){return Array.isArray(i)&&i.every(gt)}function At(i){return Array.isArray(i)&&i.every(ua)}function Gt(i){return Array.isArray(i)&&i.every(gt)}function Bt(i){return Array.isArray(i)&&i.every(St)}function Ut(i){return Array.isArray(i)&&i.every(At)}function ri(i){if(i=i.filter(function(e,t,r){return t===0||!Ji(e,r[t-1])}),i.length<2)throw new Error("LineString should contain at least 2 points");return i}function Ki(i){if(i=i.filter(function(e,t,r){return t===0||!Ji(e,r[t-1])}),fa(i)&&i.splice(-1),i.length<3)throw new Error("Ring should contain at least 3 points");return i}function dn(i){return i.map(e=>Ki(e))}function da(i){return i.map(e=>ri(e))}function pa(i){return i.map(e=>dn(e))}function lr(i){return{type:"Point",coordinates:i}}function ur(i){return{type:"LineString",coordinates:i}}function dr(i,e=!0){const t={type:"Polygon",coordinates:e?i.map(r=>[...r,r[0]]):i};return un(t)}function fa(i){return Array.isArray(i)&&i.length>=2&&Ji(i[0],i[i.length-1])}function Ji(i,e){return i===e?!0:i===null||e===null?!1:i[0]===e[0]&&i[1]===e[1]}function ma(i){return[i[0],-i[1]]}function Lr(i,e){return[(e[0]-i[0])/2+i[0],(e[1]-i[1])/2+i[1]]}function ga(i,e,t){return i*t+e*(1-t)}function ya(i,e,t){return[i[0]*t+e[0]*(1-t),i[1]*t+e[1]*(1-t)]}function bt(i,e){if(St(i)&&i.length===2)return bt(i[0],i[1]);if(gt(i)&&gt(e))return Math.sqrt((e[0]-i[0])**2+(e[1]-i[1])**2);throw new Error("Input type not supported")}function va(i){return i*(Math.PI/180)}function zt(i){return typeof i=="object"&&i!==null&&i.type==="Point"&&gt(i.coordinates)}function Wt(i){return typeof i=="object"&&i!==null&&i.type==="LineString"&&St(i.coordinates)}function Zt(i){return typeof i=="object"&&i!==null&&i.type==="Polygon"&&Array.isArray(i.coordinates)&&At(i.coordinates)}function Vt(i){return typeof i=="object"&&i!==null&&i.type==="MultiPoint"&&Gt(i.coordinates)}function qt(i){return typeof i=="object"&&i!==null&&i.type==="MultiLineString"&&Bt(i.coordinates)}function $t(i){return typeof i=="object"&&i!==null&&i.type==="MultiPolygon"&&Array.isArray(i.coordinates)&&Ut(i.coordinates)}function wa(i){const e=typeof i=="object"&&i!==null,t=e&&"type"in i&&typeof i.type=="string"&&(i.type==="Point"||i.type==="LineString"||i.type==="Polygon"||i.type==="MultiPoint"||i.type==="MultiLineString"||i.type==="MultiPolygon"),r=e&&"coordinates"in i&&Array.isArray(i.coordinates);return t&&r}function Le(i){return i.coordinates}function Oe(i){return ri(i.coordinates)}function De(i,e=!1){let t=i.coordinates;return t=dn(t),e?t.map(r=>[...r,r[0]]):t}function xa(i){return i.coordinates}function ba(i){return da(i.coordinates)}function Ma(i,e=!1){let t=i.coordinates;return t=pa(t),e?t.map(r=>r.map(s=>[...s,s[0]])):t}function Ea(i){if(zt(i))return Le(i);if(Wt(i))return Oe(i);if(Zt(i))return De(i);if(Vt(i))return xa(i);if(qt(i))return ba(i);if($t(i))return Ma(i);throw new Error("Geometry type not supported")}function pr(i){return i.coordinates.map(e=>({type:"Point",coordinates:e}))}function fr(i){return i.coordinates.map(e=>({type:"LineString",coordinates:e}))}function mr(i){return i.coordinates.map(e=>({type:"Polygon",coordinates:e}))}function gr(i){return{type:"MultiPoint",coordinates:i.map(e=>e.coordinates)}}function yr(i){return{type:"MultiLineString",coordinates:i.map(e=>e.coordinates)}}function vr(i){return{type:"MultiPolygon",coordinates:i.map(e=>e.coordinates)}}function _a(i,e){return{type:"Feature",properties:e||{},geometry:i}}function Ta(i,e){return{type:"FeatureCollection",features:i.map((t,r)=>_a(t))}}function Pa(i){return i.geometry}function Ia(i){return i.features.map(Pa)}function Ts(i){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY;for(const r of i)e===void 0?r>=r&&(e=t=r):(e>r&&(e=r),t<r&&(t=r));return[e,t]}function dt(i){if(gt(i)&&(i=[i]),At(i)&&(i=i.flat()),wa(i))return dt(Ea(i));const e=[],t=[];for(const a of i)e.push(a[0]),t.push(a[1]);const[r,s]=Ts(e),[n,o]=Ts(t);return[r,n,s,o]}function Ps(i,e){return[Math.min(i[0],e[0]),Math.min(i[1],e[1]),Math.max(i[2],e[2]),Math.max(i[3],e[3])]}function Ra(i,e){const t=i[2]>=e[0]&&e[2]>=i[0],r=i[3]>=e[1]&&e[3]>=i[1];return t&&r}function Or(i){return[[i[0],i[1]],[i[2],i[1]],[i[2],i[3]],[i[0],i[3]]]}function pn(i){return[[i[0],i[1]],[i[2],i[3]]]}function Sa(i){return bt(pn(i))}function Aa(i){return bt(pn(dt(i)))}function be(i){return[(i[0]+i[2])/2,(i[1]+i[3])/2]}function bi(i){return[i[2]-i[0],i[3]-i[1]]}function Di(i){return[.5*(bt(i[0],i[1])+bt(i[2],i[3])),.5*(bt(i[1],i[2])+bt(i[3],i[0]))]}function Dr(i,e,t){return t?t==="contain"?e[0]>=e[1]?i[0]/e[0]:i[1]/e[1]:e[0]>=e[1]?i[1]/e[1]:i[0]/e[0]:Math.sqrt(i[0]*i[1]/(e[0]*e[1]))}function Is(i,e){return Dr(Di(i),Di(e))}function Ar(i,e,t,r=!0){if(i.has(e)&&r)return i.get(e);{const s=t();return i.set(e,s),s}}function Mi(i,e,t,r,s=!0){var n,o,a;if((n=i.get(e))!=null&&n.has(t)&&s)return(o=i.get(e))==null?void 0:o.get(t);{const h=r();return i.get(e)||i.set(e,new Map),(a=i.get(e))==null||a.set(t,h),h}}function Ca(i){const e=parseInt(i.replace(/^#/,""),16),t=e>>16&255,r=e>>8&255,s=e&255;return[t,r,s]}function wr(i){return Ca(i).map(e=>e/255)}function ka(i,e){return!i||!e||i.size!==e.size?!1:[...i].every(t=>e.has(t))}function Rs(i,e){if(i!==void 0&&e!==void 0)return Math.max(i,e);if(i!==void 0)return i;if(e!==void 0)return e}function ja(i,e){e===void 0&&(e={});var t=e.offsetLine||0,r=e.offsetColumn||0,s=i.split(`
2
+ `),n=0,o=s.map(function(u,m){var g=n+u.length+1,y={start:n,end:g,line:m};return n=g,y}),a=0;function h(u,m){return u.start<=m&&m<u.end}function c(u,m){return{line:t+u.line,column:r+m-u.start,character:m}}function l(u,m){typeof u=="string"&&(u=i.indexOf(u,m||0));for(var g=o[a],y=u>=g.end?1:-1;g;){if(h(g,u))return c(g,u);a+=y,g=o[a]}}return l}function La(i,e,t){return ja(i,t)(e,t)}var Ss=/[a-zA-Z0-9:_-]/,As=/[\s\t\r\n]/,Oa=/['"]/;function Da(i,e){for(var t="";e--;)t+=i;return t}function Na(i){var e="",t=[],r=a,s=null,n=null;function o(f){var x=La(i,d),S=x.line,T=x.column,E=i.slice(0,d),p=/(^|\n).*$/.exec(E)[0].replace(/\t/g," "),b=i.slice(d),P=/.*(\n|$)/.exec(b)[0],A=""+p+P+`
3
+ `+Da(" ",p.length)+"^";throw new Error(f+" ("+S+":"+T+`). If this is valid SVG, it's probably a bug in svg-parser. Please raise an issue at https://github.com/Rich-Harris/svg-parser/issues – thanks!
4
+
5
+ `+A)}function a(){for(;d<i.length&&i[d]!=="<"||!Ss.test(i[d+1]);)e+=i[d++];return h()}function h(){for(var f="";d<i.length&&i[d]!=="<";)f+=i[d++];return/\S/.test(f)&&s.children.push({type:"text",value:f}),i[d]==="<"?c:h}function c(){var f=i[d];if(f==="?")return h;if(f==="!"){if(i.slice(d+1,d+3)==="--")return l;if(i.slice(d+1,d+8)==="[CDATA[")return u;if(/doctype/i.test(i.slice(d+1,d+8)))return h}if(f==="/")return m;var x=g(),S={type:"element",tagName:x,properties:{},children:[]};s?s.children.push(S):n=S;for(var T;d<i.length&&(T=y());)S.properties[T.name]=T.value;var E=!1;return i[d]==="/"&&(d+=1,E=!0),i[d]!==">"&&o("Expected >"),E||(s=S,t.push(S)),h}function l(){var f=i.indexOf("-->",d);return~f||o("expected -->"),d=f+2,h}function u(){var f=i.indexOf("]]>",d);return~f||o("expected ]]>"),s.children.push(i.slice(d+7,f)),d=f+2,h}function m(){var f=g();return f||o("Expected tag name"),f!==s.tagName&&o("Expected closing tag </"+f+"> to match opening tag <"+s.tagName+">"),R(),i[d]!==">"&&o("Expected >"),t.pop(),s=t[t.length-1],h}function g(){for(var f="";d<i.length&&Ss.test(i[d]);)f+=i[d++];return f}function y(){if(!As.test(i[d]))return null;R();var f=g();if(!f)return null;var x=!0;return R(),i[d]==="="&&(d+=1,R(),x=_(),!isNaN(x)&&x.trim()!==""&&(x=+x)),{name:f,value:x}}function _(){return Oa.test(i[d])?w():I()}function I(){var f="";do{var x=i[d];if(x===" "||x===">"||x==="/")return f;f+=x,d+=1}while(d<i.length);return f}function w(){for(var f=i[d++],x="",S=!1;d<i.length;){var T=i[d++];if(T===f&&!S)return x;T==="\\"&&!S&&(S=!0),x+=S?"\\"+T:T,S=!1}}function R(){for(;d<i.length&&As.test(i[d]);)d+=1}for(var d=a.length;d<i.length;)r||o("Unexpected character"),r=r(),d+=1;return r!==h&&o("Unexpected end of input"),n.tagName==="svg"&&(n.metadata=e),{type:"root",children:[n]}}function*Fa(i){function*e(r){if("children"in r)for(const s of r.children)typeof s!="string"&&(yield*e(s));yield r}const t=Na(i);for(const r of e(t))if("tagName"in r&&r.tagName!=="svg"&&r.tagName!=="g"){const s=Ga(r);s&&(yield s)}}function Ga(i){var t;const e=(t=i==null?void 0:i.tagName)==null?void 0:t.toLowerCase();if(e==="circle")return{type:"circle",coordinates:[st(i,"cx"),st(i,"cy")]};if(e==="line")return{type:"line",coordinates:[[st(i,"x1"),st(i,"y1")],[st(i,"x2"),st(i,"y2")]]};if(e==="polyline")return{type:"polyline",coordinates:Cs(i)};if(e==="polygon")return{type:"polygon",coordinates:Cs(i)};if(e==="rect")return{type:"rect",coordinates:[[st(i,"x"),st(i,"y")],[st(i,"x")+st(i,"width"),st(i,"y")],[st(i,"x")+st(i,"width"),st(i,"y")+st(i,"height")],[st(i,"x"),st(i,"y")+st(i,"height")],[st(i,"x"),st(i,"y")]]};throw new Error(`Unsupported SVG element: ${e}`)}function st(i,e){var r;const t=(r=i==null?void 0:i.properties)==null?void 0:r[e];return Number(t)||0}function Cs(i){var t;const e=(t=i==null?void 0:i.properties)==null?void 0:t.points;return e?String(e).trim().split(/\s+/).map(r=>{const s=r.split(",").map(n=>Number(n));return[s[0],s[1]]}):[]}function ks(i){return i.map(e=>e.join(",")).join(" ")}function Ba(i){return`<svg xmlns="http://www.w3.org/2000/svg">
6
+ ${i.map(Ua).join(`
7
+ `)}
8
+ </svg>`}function Ua(i){if(i.type==="circle")return Ae("circle",{...i.attributes,cx:i.coordinates[0],cy:i.coordinates[1]});if(i.type==="line")return Ae("line",{...i.attributes,x1:i.coordinates[0][0],y1:i.coordinates[0][1],x2:i.coordinates[1][0],y2:i.coordinates[1][1]});if(i.type==="polyline")return Ae("polyline",{...i.attributes,points:ks(i.coordinates)});if(i.type==="polygon")return Ae("polygon",{...i.attributes,points:ks(i.coordinates)});if(i.type==="rect")return Ae("rect",{...i.attributes,x:i.coordinates[0][0],y:i.coordinates[0][1],width:i.coordinates[1][0]-i.coordinates[0][0],height:i.coordinates[2][1]-i.coordinates[0][1]});throw new Error("Unknown SVG element")}function Ae(i,e){const t=Object.entries(e).map(([r,s])=>`${r}="${s}"`);return`<${i} ${t.join(" ")} />`}function fe([i,e]){const t=6378137*va(i),r=t/i,s=180/Math.PI*Math.log(Math.tan(Math.PI/4+e*(Math.PI/180)/2))*r;return[t,s]}function js([i,e]){const t=Math.PI*6378137,r=i/t*180;let s=e/t*180;return s=180/Math.PI*(2*Math.atan(Math.exp(s*Math.PI/180))-Math.PI/2),[r,s]}class Nr{constructor(e,t,r,s,n=1){M(this,"geoCenter");M(this,"geoRectangle");M(this,"geoSize");M(this,"geoRectangleBbox");M(this,"projectedGeoCenter");M(this,"projectedGeoRectangle");M(this,"projectedGeoSize");M(this,"projectedGeoRectangleBbox");M(this,"rotation");M(this,"projectedGeoPerViewportScale");M(this,"viewportCenter");M(this,"viewportRectangle");M(this,"viewportSize");M(this,"viewportBbox");M(this,"devicePixelRatio");M(this,"canvasCenter");M(this,"canvasRectangle");M(this,"canvasSize");M(this,"canvasBbox");M(this,"projectedGeoPerCanvasScale");M(this,"projectedGeoToViewportTransform",[1,0,0,1,0,0]);M(this,"projectedGeoToClipTransform",[1,0,0,1,0,0]);this.projectedGeoCenter=t,this.projectedGeoPerViewportScale=r,this.rotation=s,this.viewportSize=e,this.devicePixelRatio=n,this.projectedGeoRectangle=this.computeProjectedGeoRectangle(this.projectedGeoCenter,this.projectedGeoPerViewportScale,this.rotation,this.viewportSize),this.projectedGeoRectangleBbox=dt(this.projectedGeoRectangle),this.projectedGeoSize=[this.viewportSize[0]*r,this.viewportSize[1]*r],this.geoCenter=js(this.projectedGeoCenter),this.geoRectangle=this.projectedGeoRectangle.map(o=>js(o)),this.geoRectangleBbox=dt(this.geoRectangle),this.geoSize=bi(this.geoRectangleBbox),this.viewportCenter=[this.viewportSize[0]/2,this.viewportSize[1]/2],this.viewportBbox=[0,0,...this.viewportSize],this.viewportRectangle=Or(this.viewportBbox),this.canvasCenter=[this.viewportCenter[0]*this.devicePixelRatio,this.viewportSize[1]*this.devicePixelRatio],this.canvasSize=[this.viewportSize[0]*this.devicePixelRatio,this.viewportSize[1]*this.devicePixelRatio],this.canvasBbox=[0,0,...this.canvasSize],this.canvasRectangle=Or(this.canvasBbox),this.projectedGeoPerCanvasScale=this.projectedGeoPerViewportScale/this.devicePixelRatio,this.projectedGeoToViewportTransform=this.composeProjectedGeoToViewportTransform(),this.projectedGeoToClipTransform=this.composeProjectedGeoToClipTransform()}static fromWarpedMapList(e,t,r,s="contain",n=1){const o=t.getProjectedCenter(),a=t.getProjectedBbox();if(!o||!a)throw new Error("WarpedMapList has no projected center or bbox");const h=bi(a),c=Dr(h,e,s)*(1/n);return new Nr(e,o,c,0,r)}static fromProjectedGeoBbox(e,t,r,s="contain"){const n=be(t),o=bi(t),a=Dr(o,e,s);return new Nr(e,n,a,0,r)}composeProjectedGeoToViewportTransform(){return Es(this.viewportSize[0]/2,this.viewportSize[1]/2,1/this.projectedGeoPerViewportScale,-1/this.projectedGeoPerViewportScale,-this.rotation,-this.projectedGeoCenter[0],-this.projectedGeoCenter[1])}composeProjectedGeoToClipTransform(){return Es(0,0,2/(this.projectedGeoPerViewportScale*this.viewportSize[0]),2/(this.projectedGeoPerViewportScale*this.viewportSize[1]),-this.rotation,-this.projectedGeoCenter[0],-this.projectedGeoCenter[1])}computeProjectedGeoRectangle(e,t,r,s){const n=t*s[0]/2,o=t*s[1]/2,a=Math.cos(r),h=Math.sin(r),c=n*a,l=n*h,u=o*a,m=o*h,g=e[0],y=e[1];return[[g-c+m,y-l-u],[g-c-m,y-l+u],[g+c-m,y+l+u],[g+c+m,y+l-u]]}}function Ni(i){return Array.isArray(i)?`[${i.map(e=>Ni(e)).join(",")}]`:typeof i=="number"?`${i}`:typeof i=="string"?`"${i}"`:typeof i=="object"&&i!==null?Object.keys(i).sort().map(e=>`${e}:${Ni(i[e])}`).join("|"):String(i)}async function za(i){const e=await crypto.subtle.digest("SHA-1",new TextEncoder().encode(i));return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}async function fn(i,e=16){return(await za(String(i))).slice(0,e)}async function Wa(i,e){return await fn(Ni(i),e)}var H;(function(i){i.assertEqual=s=>s;function e(s){}i.assertIs=e;function t(s){throw new Error}i.assertNever=t,i.arrayToEnum=s=>{const n={};for(const o of s)n[o]=o;return n},i.getValidEnumValues=s=>{const n=i.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of n)o[a]=s[a];return i.objectValues(o)},i.objectValues=s=>i.objectKeys(s).map(function(n){return s[n]}),i.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const n=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&n.push(o);return n},i.find=(s,n)=>{for(const o of s)if(n(o))return o},i.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,n=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(n)}i.joinValues=r,i.jsonStringifyReplacer=(s,n)=>typeof n=="bigint"?n.toString():n})(H||(H={}));var Fi;(function(i){i.mergeShapes=(e,t)=>({...e,...t})})(Fi||(Fi={}));const O=H.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Jt=i=>{switch(typeof i){case"undefined":return O.undefined;case"string":return O.string;case"number":return isNaN(i)?O.nan:O.number;case"boolean":return O.boolean;case"function":return O.function;case"bigint":return O.bigint;case"symbol":return O.symbol;case"object":return Array.isArray(i)?O.array:i===null?O.null:i.then&&typeof i.then=="function"&&i.catch&&typeof i.catch=="function"?O.promise:typeof Map<"u"&&i instanceof Map?O.map:typeof Set<"u"&&i instanceof Set?O.set:typeof Date<"u"&&i instanceof Date?O.date:O.object;default:return O.unknown}},C=H.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Za=i=>JSON.stringify(i,null,2).replace(/"([^"]+)":/g,"$1:");class Mt extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(n){return n.message},r={_errors:[]},s=n=>{for(const o of n.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let a=r,h=0;for(;h<o.path.length;){const c=o.path[h];h===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(o))):a[c]=a[c]||{_errors:[]},a=a[c],h++}}};return s(this),r}static assert(e){if(!(e instanceof Mt))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,H.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}Mt.create=i=>new Mt(i);const Me=(i,e)=>{let t;switch(i.code){case C.invalid_type:i.received===O.undefined?t="Required":t=`Expected ${i.expected}, received ${i.received}`;break;case C.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(i.expected,H.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:t=`Unrecognized key(s) in object: ${H.joinValues(i.keys,", ")}`;break;case C.invalid_union:t="Invalid input";break;case C.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${H.joinValues(i.options)}`;break;case C.invalid_enum_value:t=`Invalid enum value. Expected ${H.joinValues(i.options)}, received '${i.received}'`;break;case C.invalid_arguments:t="Invalid function arguments";break;case C.invalid_return_type:t="Invalid function return type";break;case C.invalid_date:t="Invalid date";break;case C.invalid_string:typeof i.validation=="object"?"includes"in i.validation?(t=`Invalid input: must include "${i.validation.includes}"`,typeof i.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${i.validation.position}`)):"startsWith"in i.validation?t=`Invalid input: must start with "${i.validation.startsWith}"`:"endsWith"in i.validation?t=`Invalid input: must end with "${i.validation.endsWith}"`:H.assertNever(i.validation):i.validation!=="regex"?t=`Invalid ${i.validation}`:t="Invalid";break;case C.too_small:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at least":"more than"} ${i.minimum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at least":"over"} ${i.minimum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${i.minimum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly equal to ":i.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(i.minimum))}`:t="Invalid input";break;case C.too_big:i.type==="array"?t=`Array must contain ${i.exact?"exactly":i.inclusive?"at most":"less than"} ${i.maximum} element(s)`:i.type==="string"?t=`String must contain ${i.exact?"exactly":i.inclusive?"at most":"under"} ${i.maximum} character(s)`:i.type==="number"?t=`Number must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="bigint"?t=`BigInt must be ${i.exact?"exactly":i.inclusive?"less than or equal to":"less than"} ${i.maximum}`:i.type==="date"?t=`Date must be ${i.exact?"exactly":i.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(i.maximum))}`:t="Invalid input";break;case C.custom:t="Invalid input";break;case C.invalid_intersection_types:t="Intersection results could not be merged";break;case C.not_multiple_of:t=`Number must be a multiple of ${i.multipleOf}`;break;case C.not_finite:t="Number must be finite";break;default:t=e.defaultError,H.assertNever(i)}return{message:t}};let mn=Me;function Va(i){mn=i}function Fr(){return mn}const Gr=i=>{const{data:e,path:t,errorMaps:r,issueData:s}=i,n=[...t,...s.path||[]],o={...s,path:n};if(s.message!==void 0)return{...s,path:n,message:s.message};let a="";const h=r.filter(c=>!!c).slice().reverse();for(const c of h)a=c(o,{data:e,defaultError:a}).message;return{...s,path:n,message:a}},qa=[];function L(i,e){const t=Fr(),r=Gr({issueData:e,data:i.data,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,t,t===Me?void 0:Me].filter(s=>!!s)});i.common.issues.push(r)}class pt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return F;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const n=await s.key,o=await s.value;r.push({key:n,value:o})}return pt.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:n,value:o}=s;if(n.status==="aborted"||o.status==="aborted")return F;n.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[n.value]=o.value)}return{status:e.value,value:r}}}const F=Object.freeze({status:"aborted"}),Br=i=>({status:"dirty",value:i}),yt=i=>({status:"valid",value:i}),Gi=i=>i.status==="aborted",Bi=i=>i.status==="dirty",Ue=i=>i.status==="valid",ze=i=>typeof Promise<"u"&&i instanceof Promise;function Ur(i,e,t,r){if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(i)}function gn(i,e,t,r,s){if(typeof e=="function"?i!==e||!s:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(i,t),t}var D;(function(i){i.errToObj=e=>typeof e=="string"?{message:e}:e||{},i.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(D||(D={}));var Ne,Fe;class Dt{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ls=(i,e)=>{if(Ue(e))return{success:!0,data:e.value};if(!i.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Mt(i.common.issues);return this._error=t,this._error}}};function G(i){if(!i)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=i;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(n,o)=>{var a,h;const{message:c}=i;return n.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:(a=c??r)!==null&&a!==void 0?a:o.defaultError}:n.code!=="invalid_type"?{message:o.defaultError}:{message:(h=c??t)!==null&&h!==void 0?h:o.defaultError}},description:s}}class W{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Jt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Jt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new pt,ctx:{common:e.parent.common,data:e.data,parsedType:Jt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ze(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Jt(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Ls(s,n)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Jt(e)},s=this._parse({data:e,path:r.path,parent:r}),n=await(ze(s)?s:Promise.resolve(s));return Ls(r,n)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,n)=>{const o=e(s),a=()=>n.addIssue({code:C.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(h=>h?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new Lt({schema:this,typeName:N.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Ot.create(this,this._def)}nullable(){return re.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return jt.create(this,this._def)}promise(){return _e.create(this,this._def)}or(e){return qe.create([this,e],this._def)}and(e){return $e.create(this,e,this._def)}transform(e){return new Lt({...G(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Je({...G(this._def),innerType:this,defaultValue:t,typeName:N.ZodDefault})}brand(){return new Qi({typeName:N.ZodBranded,type:this,...G(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Qe({...G(this._def),innerType:this,catchValue:t,typeName:N.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return sr.create(this,e)}readonly(){return tr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const $a=/^c[^\s-]{8,}$/i,Xa=/^[0-9a-z]+$/,Ha=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ya=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ka=/^[a-z0-9_-]{21}$/i,Ja=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Qa=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,th="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ei;const eh=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,rh=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ih=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",sh=new RegExp(`^${yn}$`);function vn(i){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return i.precision?e=`${e}\\.\\d{${i.precision}}`:i.precision==null&&(e=`${e}(\\.\\d+)?`),e}function nh(i){return new RegExp(`^${vn(i)}$`)}function wn(i){let e=`${yn}T${vn(i)}`;const t=[];return t.push(i.local?"Z?":"Z"),i.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function oh(i,e){return!!((e==="v4"||!e)&&eh.test(i)||(e==="v6"||!e)&&rh.test(i))}class Ct extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==O.string){const s=this._getOrReturnCtx(e);return L(s,{code:C.invalid_type,expected:O.string,received:s.parsedType}),F}const t=new pt;let r;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),L(r,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),L(r,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const n=e.data.length>s.value,o=e.data.length<s.value;(n||o)&&(r=this._getOrReturnCtx(e,r),n?L(r,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&L(r,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Qa.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"email",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Ei||(Ei=new RegExp(th,"u")),Ei.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"emoji",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")Ya.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"uuid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")Ka.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"nanoid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")$a.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"cuid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")Xa.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"cuid2",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")Ha.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"ulid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),L(r,{validation:"url",code:C.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"regex",code:C.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),L(r,{code:C.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(r=this._getOrReturnCtx(e,r),L(r,{code:C.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),L(r,{code:C.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?wn(s).test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{code:C.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?sh.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{code:C.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?nh(s).test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{code:C.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?Ja.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"duration",code:C.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?oh(e.data,s.version)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"ip",code:C.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?ih.test(e.data)||(r=this._getOrReturnCtx(e,r),L(r,{validation:"base64",code:C.invalid_string,message:s.message}),t.dirty()):H.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:C.invalid_string,...D.errToObj(r)})}_addCheck(e){return new Ct({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...D.errToObj(e)})}url(e){return this._addCheck({kind:"url",...D.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...D.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...D.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...D.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...D.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...D.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...D.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...D.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...D.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...D.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...D.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...D.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...D.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...D.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...D.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...D.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...D.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...D.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...D.errToObj(t)})}nonempty(e){return this.min(1,D.errToObj(e))}trim(){return new Ct({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ct({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ct({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ct.create=i=>{var e;return new Ct({checks:[],typeName:N.ZodString,coerce:(e=i==null?void 0:i.coerce)!==null&&e!==void 0?e:!1,...G(i)})};function ah(i,e){const t=(i.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,n=parseInt(i.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return n%o/Math.pow(10,s)}class Qt extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==O.number){const s=this._getOrReturnCtx(e);return L(s,{code:C.invalid_type,expected:O.number,received:s.parsedType}),F}let t;const r=new pt;for(const s of this._def.checks)s.kind==="int"?H.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),L(t,{code:C.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:C.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:C.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?ah(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),L(t,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),L(t,{code:C.not_finite,message:s.message}),r.dirty()):H.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,D.toString(t))}gt(e,t){return this.setLimit("min",e,!1,D.toString(t))}lte(e,t){return this.setLimit("max",e,!0,D.toString(t))}lt(e,t){return this.setLimit("max",e,!1,D.toString(t))}setLimit(e,t,r,s){return new Qt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:D.toString(s)}]})}_addCheck(e){return new Qt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:D.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:D.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:D.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:D.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:D.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:D.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:D.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:D.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:D.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&H.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Qt.create=i=>new Qt({checks:[],typeName:N.ZodNumber,coerce:(i==null?void 0:i.coerce)||!1,...G(i)});class te extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==O.bigint){const s=this._getOrReturnCtx(e);return L(s,{code:C.invalid_type,expected:O.bigint,received:s.parsedType}),F}let t;const r=new pt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:C.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:C.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),L(t,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):H.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,D.toString(t))}gt(e,t){return this.setLimit("min",e,!1,D.toString(t))}lte(e,t){return this.setLimit("max",e,!0,D.toString(t))}lt(e,t){return this.setLimit("max",e,!1,D.toString(t))}setLimit(e,t,r,s){return new te({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:D.toString(s)}]})}_addCheck(e){return new te({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:D.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:D.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:D.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:D.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:D.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}te.create=i=>{var e;return new te({checks:[],typeName:N.ZodBigInt,coerce:(e=i==null?void 0:i.coerce)!==null&&e!==void 0?e:!1,...G(i)})};class We extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==O.boolean){const t=this._getOrReturnCtx(e);return L(t,{code:C.invalid_type,expected:O.boolean,received:t.parsedType}),F}return yt(e.data)}}We.create=i=>new We({typeName:N.ZodBoolean,coerce:(i==null?void 0:i.coerce)||!1,...G(i)});class ae extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==O.date){const s=this._getOrReturnCtx(e);return L(s,{code:C.invalid_type,expected:O.date,received:s.parsedType}),F}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return L(s,{code:C.invalid_date}),F}const t=new pt;let r;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),L(r,{code:C.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),L(r,{code:C.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):H.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ae({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:D.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:D.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ae.create=i=>new ae({checks:[],coerce:(i==null?void 0:i.coerce)||!1,typeName:N.ZodDate,...G(i)});class zr extends W{_parse(e){if(this._getType(e)!==O.symbol){const t=this._getOrReturnCtx(e);return L(t,{code:C.invalid_type,expected:O.symbol,received:t.parsedType}),F}return yt(e.data)}}zr.create=i=>new zr({typeName:N.ZodSymbol,...G(i)});class Ze extends W{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return L(t,{code:C.invalid_type,expected:O.undefined,received:t.parsedType}),F}return yt(e.data)}}Ze.create=i=>new Ze({typeName:N.ZodUndefined,...G(i)});class Ve extends W{_parse(e){if(this._getType(e)!==O.null){const t=this._getOrReturnCtx(e);return L(t,{code:C.invalid_type,expected:O.null,received:t.parsedType}),F}return yt(e.data)}}Ve.create=i=>new Ve({typeName:N.ZodNull,...G(i)});class Ee extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return yt(e.data)}}Ee.create=i=>new Ee({typeName:N.ZodAny,...G(i)});class ne extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return yt(e.data)}}ne.create=i=>new ne({typeName:N.ZodUnknown,...G(i)});class Ht extends W{_parse(e){const t=this._getOrReturnCtx(e);return L(t,{code:C.invalid_type,expected:O.never,received:t.parsedType}),F}}Ht.create=i=>new Ht({typeName:N.ZodNever,...G(i)});class Wr extends W{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return L(t,{code:C.invalid_type,expected:O.void,received:t.parsedType}),F}return yt(e.data)}}Wr.create=i=>new Wr({typeName:N.ZodVoid,...G(i)});class jt extends W{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==O.array)return L(t,{code:C.invalid_type,expected:O.array,received:t.parsedType}),F;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;(o||a)&&(L(t,{code:o?C.too_big:C.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(L(t,{code:C.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(L(t,{code:C.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,a)=>s.type._parseAsync(new Dt(t,o,t.path,a)))).then(o=>pt.mergeArray(r,o));const n=[...t.data].map((o,a)=>s.type._parseSync(new Dt(t,o,t.path,a)));return pt.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new jt({...this._def,minLength:{value:e,message:D.toString(t)}})}max(e,t){return new jt({...this._def,maxLength:{value:e,message:D.toString(t)}})}length(e,t){return new jt({...this._def,exactLength:{value:e,message:D.toString(t)}})}nonempty(e){return this.min(1,e)}}jt.create=(i,e)=>new jt({type:i,minLength:null,maxLength:null,exactLength:null,typeName:N.ZodArray,...G(e)});function me(i){if(i instanceof et){const e={};for(const t in i.shape){const r=i.shape[t];e[t]=Ot.create(me(r))}return new et({...i._def,shape:()=>e})}else return i instanceof jt?new jt({...i._def,type:me(i.element)}):i instanceof Ot?Ot.create(me(i.unwrap())):i instanceof re?re.create(me(i.unwrap())):i instanceof Nt?Nt.create(i.items.map(e=>me(e))):i}class et extends W{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=H.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==O.object){const h=this._getOrReturnCtx(e);return L(h,{code:C.invalid_type,expected:O.object,received:h.parsedType}),F}const{status:t,ctx:r}=this._processInputParams(e),{shape:s,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof Ht&&this._def.unknownKeys==="strip"))for(const h in r.data)n.includes(h)||o.push(h);const a=[];for(const h of n){const c=s[h],l=r.data[h];a.push({key:{status:"valid",value:h},value:c._parse(new Dt(r,l,r.path,h)),alwaysSet:h in r.data})}if(this._def.catchall instanceof Ht){const h=this._def.unknownKeys;if(h==="passthrough")for(const c of o)a.push({key:{status:"valid",value:c},value:{status:"valid",value:r.data[c]}});else if(h==="strict")o.length>0&&(L(r,{code:C.unrecognized_keys,keys:o}),t.dirty());else if(h!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const h=this._def.catchall;for(const c of o){const l=r.data[c];a.push({key:{status:"valid",value:c},value:h._parse(new Dt(r,l,r.path,c)),alwaysSet:c in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const h=[];for(const c of a){const l=await c.key,u=await c.value;h.push({key:l,value:u,alwaysSet:c.alwaysSet})}return h}).then(h=>pt.mergeObjectSync(t,h)):pt.mergeObjectSync(t,a)}get shape(){return this._def.shape()}strict(e){return D.errToObj,new et({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,n,o,a;const h=(o=(n=(s=this._def).errorMap)===null||n===void 0?void 0:n.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(a=D.errToObj(e).message)!==null&&a!==void 0?a:h}:{message:h}}}:{}})}strip(){return new et({...this._def,unknownKeys:"strip"})}passthrough(){return new et({...this._def,unknownKeys:"passthrough"})}extend(e){return new et({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new et({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:N.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new et({...this._def,catchall:e})}pick(e){const t={};return H.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new et({...this._def,shape:()=>t})}omit(e){const t={};return H.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new et({...this._def,shape:()=>t})}deepPartial(){return me(this)}partial(e){const t={};return H.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new et({...this._def,shape:()=>t})}required(e){const t={};return H.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ot;)s=s._def.innerType;t[r]=s}}),new et({...this._def,shape:()=>t})}keyof(){return xn(H.objectKeys(this.shape))}}et.create=(i,e)=>new et({shape:()=>i,unknownKeys:"strip",catchall:Ht.create(),typeName:N.ZodObject,...G(e)});et.strictCreate=(i,e)=>new et({shape:()=>i,unknownKeys:"strict",catchall:Ht.create(),typeName:N.ZodObject,...G(e)});et.lazycreate=(i,e)=>new et({shape:i,unknownKeys:"strip",catchall:Ht.create(),typeName:N.ZodObject,...G(e)});class qe extends W{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(n){for(const a of n)if(a.result.status==="valid")return a.result;for(const a of n)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;const o=n.map(a=>new Mt(a.ctx.common.issues));return L(t,{code:C.invalid_union,unionErrors:o}),F}if(t.common.async)return Promise.all(r.map(async n=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let n;const o=[];for(const h of r){const c={...t,common:{...t.common,issues:[]},parent:null},l=h._parseSync({data:t.data,path:t.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!n&&(n={result:l,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const a=o.map(h=>new Mt(h));return L(t,{code:C.invalid_union,unionErrors:a}),F}}get options(){return this._def.options}}qe.create=(i,e)=>new qe({options:i,typeName:N.ZodUnion,...G(e)});const Kt=i=>i instanceof He?Kt(i.schema):i instanceof Lt?Kt(i.innerType()):i instanceof Ye?[i.value]:i instanceof ee?i.options:i instanceof Ke?H.objectValues(i.enum):i instanceof Je?Kt(i._def.innerType):i instanceof Ze?[void 0]:i instanceof Ve?[null]:i instanceof Ot?[void 0,...Kt(i.unwrap())]:i instanceof re?[null,...Kt(i.unwrap())]:i instanceof Qi||i instanceof tr?Kt(i.unwrap()):i instanceof Qe?Kt(i._def.innerType):[];class ii extends W{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.object)return L(t,{code:C.invalid_type,expected:O.object,received:t.parsedType}),F;const r=this.discriminator,s=t.data[r],n=this.optionsMap.get(s);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(L(t,{code:C.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),F)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const n of t){const o=Kt(n.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,n)}}return new ii({typeName:N.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...G(r)})}}function Ui(i,e){const t=Jt(i),r=Jt(e);if(i===e)return{valid:!0,data:i};if(t===O.object&&r===O.object){const s=H.objectKeys(e),n=H.objectKeys(i).filter(a=>s.indexOf(a)!==-1),o={...i,...e};for(const a of n){const h=Ui(i[a],e[a]);if(!h.valid)return{valid:!1};o[a]=h.data}return{valid:!0,data:o}}else if(t===O.array&&r===O.array){if(i.length!==e.length)return{valid:!1};const s=[];for(let n=0;n<i.length;n++){const o=i[n],a=e[n],h=Ui(o,a);if(!h.valid)return{valid:!1};s.push(h.data)}return{valid:!0,data:s}}else return t===O.date&&r===O.date&&+i==+e?{valid:!0,data:i}:{valid:!1}}class $e extends W{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(n,o)=>{if(Gi(n)||Gi(o))return F;const a=Ui(n.value,o.value);return a.valid?((Bi(n)||Bi(o))&&t.dirty(),{status:t.value,value:a.data}):(L(r,{code:C.invalid_intersection_types}),F)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([n,o])=>s(n,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}$e.create=(i,e,t)=>new $e({left:i,right:e,typeName:N.ZodIntersection,...G(t)});class Nt extends W{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==O.array)return L(r,{code:C.invalid_type,expected:O.array,received:r.parsedType}),F;if(r.data.length<this._def.items.length)return L(r,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),F;!this._def.rest&&r.data.length>this._def.items.length&&(L(r,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((n,o)=>{const a=this._def.items[o]||this._def.rest;return a?a._parse(new Dt(r,n,r.path,o)):null}).filter(n=>!!n);return r.common.async?Promise.all(s).then(n=>pt.mergeArray(t,n)):pt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Nt({...this._def,rest:e})}}Nt.create=(i,e)=>{if(!Array.isArray(i))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nt({items:i,typeName:N.ZodTuple,rest:null,...G(e)})};class Xe extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==O.object)return L(r,{code:C.invalid_type,expected:O.object,received:r.parsedType}),F;const s=[],n=this._def.keyType,o=this._def.valueType;for(const a in r.data)s.push({key:n._parse(new Dt(r,a,r.path,a)),value:o._parse(new Dt(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?pt.mergeObjectAsync(t,s):pt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof W?new Xe({keyType:e,valueType:t,typeName:N.ZodRecord,...G(r)}):new Xe({keyType:Ct.create(),valueType:e,typeName:N.ZodRecord,...G(t)})}}class Zr extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==O.map)return L(r,{code:C.invalid_type,expected:O.map,received:r.parsedType}),F;const s=this._def.keyType,n=this._def.valueType,o=[...r.data.entries()].map(([a,h],c)=>({key:s._parse(new Dt(r,a,r.path,[c,"key"])),value:n._parse(new Dt(r,h,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const h of o){const c=await h.key,l=await h.value;if(c.status==="aborted"||l.status==="aborted")return F;(c.status==="dirty"||l.status==="dirty")&&t.dirty(),a.set(c.value,l.value)}return{status:t.value,value:a}})}else{const a=new Map;for(const h of o){const c=h.key,l=h.value;if(c.status==="aborted"||l.status==="aborted")return F;(c.status==="dirty"||l.status==="dirty")&&t.dirty(),a.set(c.value,l.value)}return{status:t.value,value:a}}}}Zr.create=(i,e,t)=>new Zr({valueType:e,keyType:i,typeName:N.ZodMap,...G(t)});class he extends W{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==O.set)return L(r,{code:C.invalid_type,expected:O.set,received:r.parsedType}),F;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(L(r,{code:C.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(L(r,{code:C.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const n=this._def.valueType;function o(h){const c=new Set;for(const l of h){if(l.status==="aborted")return F;l.status==="dirty"&&t.dirty(),c.add(l.value)}return{status:t.value,value:c}}const a=[...r.data.values()].map((h,c)=>n._parse(new Dt(r,h,r.path,c)));return r.common.async?Promise.all(a).then(h=>o(h)):o(a)}min(e,t){return new he({...this._def,minSize:{value:e,message:D.toString(t)}})}max(e,t){return new he({...this._def,maxSize:{value:e,message:D.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}he.create=(i,e)=>new he({valueType:i,minSize:null,maxSize:null,typeName:N.ZodSet,...G(e)});class xe extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.function)return L(t,{code:C.invalid_type,expected:O.function,received:t.parsedType}),F;function r(a,h){return Gr({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Fr(),Me].filter(c=>!!c),issueData:{code:C.invalid_arguments,argumentsError:h}})}function s(a,h){return Gr({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Fr(),Me].filter(c=>!!c),issueData:{code:C.invalid_return_type,returnTypeError:h}})}const n={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof _e){const a=this;return yt(async function(...h){const c=new Mt([]),l=await a._def.args.parseAsync(h,n).catch(m=>{throw c.addIssue(r(h,m)),c}),u=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(u,n).catch(m=>{throw c.addIssue(s(u,m)),c})})}else{const a=this;return yt(function(...h){const c=a._def.args.safeParse(h,n);if(!c.success)throw new Mt([r(h,c.error)]);const l=Reflect.apply(o,this,c.data),u=a._def.returns.safeParse(l,n);if(!u.success)throw new Mt([s(l,u.error)]);return u.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new xe({...this._def,args:Nt.create(e).rest(ne.create())})}returns(e){return new xe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new xe({args:e||Nt.create([]).rest(ne.create()),returns:t||ne.create(),typeName:N.ZodFunction,...G(r)})}}class He extends W{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}He.create=(i,e)=>new He({getter:i,typeName:N.ZodLazy,...G(e)});class Ye extends W{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return L(t,{received:t.data,code:C.invalid_literal,expected:this._def.value}),F}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ye.create=(i,e)=>new Ye({value:i,typeName:N.ZodLiteral,...G(e)});function xn(i,e){return new ee({values:i,typeName:N.ZodEnum,...G(e)})}class ee extends W{constructor(){super(...arguments),Ne.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return L(t,{expected:H.joinValues(r),received:t.parsedType,code:C.invalid_type}),F}if(Ur(this,Ne)||gn(this,Ne,new Set(this._def.values)),!Ur(this,Ne).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return L(t,{received:t.data,code:C.invalid_enum_value,options:r}),F}return yt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ee.create(e,{...this._def,...t})}exclude(e,t=this._def){return ee.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Ne=new WeakMap;ee.create=xn;class Ke extends W{constructor(){super(...arguments),Fe.set(this,void 0)}_parse(e){const t=H.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==O.string&&r.parsedType!==O.number){const s=H.objectValues(t);return L(r,{expected:H.joinValues(s),received:r.parsedType,code:C.invalid_type}),F}if(Ur(this,Fe)||gn(this,Fe,new Set(H.getValidEnumValues(this._def.values))),!Ur(this,Fe).has(e.data)){const s=H.objectValues(t);return L(r,{received:r.data,code:C.invalid_enum_value,options:s}),F}return yt(e.data)}get enum(){return this._def.values}}Fe=new WeakMap;Ke.create=(i,e)=>new Ke({values:i,typeName:N.ZodNativeEnum,...G(e)});class _e extends W{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.promise&&t.common.async===!1)return L(t,{code:C.invalid_type,expected:O.promise,received:t.parsedType}),F;const r=t.parsedType===O.promise?t.data:Promise.resolve(t.data);return yt(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}_e.create=(i,e)=>new _e({type:i,typeName:N.ZodPromise,...G(e)});class Lt extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===N.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,n={addIssue:o=>{L(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),s.type==="preprocess"){const o=s.transform(r.data,n);if(r.common.async)return Promise.resolve(o).then(async a=>{if(t.value==="aborted")return F;const h=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return h.status==="aborted"?F:h.status==="dirty"||t.value==="dirty"?Br(h.value):h});{if(t.value==="aborted")return F;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?F:a.status==="dirty"||t.value==="dirty"?Br(a.value):a}}if(s.type==="refinement"){const o=a=>{const h=s.refinement(a,n);if(r.common.async)return Promise.resolve(h);if(h instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?F:(a.status==="dirty"&&t.dirty(),o(a.value),{status:t.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?F:(a.status==="dirty"&&t.dirty(),o(a.value).then(()=>({status:t.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ue(o))return o;const a=s.transform(o.value,n);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ue(o)?Promise.resolve(s.transform(o.value,n)).then(a=>({status:t.value,value:a})):o);H.assertNever(s)}}Lt.create=(i,e,t)=>new Lt({schema:i,typeName:N.ZodEffects,effect:e,...G(t)});Lt.createWithPreprocess=(i,e,t)=>new Lt({schema:e,effect:{type:"preprocess",transform:i},typeName:N.ZodEffects,...G(t)});class Ot extends W{_parse(e){return this._getType(e)===O.undefined?yt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ot.create=(i,e)=>new Ot({innerType:i,typeName:N.ZodOptional,...G(e)});class re extends W{_parse(e){return this._getType(e)===O.null?yt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}re.create=(i,e)=>new re({innerType:i,typeName:N.ZodNullable,...G(e)});class Je extends W{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===O.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Je.create=(i,e)=>new Je({innerType:i,typeName:N.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});class Qe extends W{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ze(s)?s.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Mt(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Mt(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Qe.create=(i,e)=>new Qe({innerType:i,typeName:N.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});class Vr extends W{_parse(e){if(this._getType(e)!==O.nan){const t=this._getOrReturnCtx(e);return L(t,{code:C.invalid_type,expected:O.nan,received:t.parsedType}),F}return{status:"valid",value:e.data}}}Vr.create=i=>new Vr({typeName:N.ZodNaN,...G(i)});const hh=Symbol("zod_brand");class Qi extends W{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class sr extends W{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?F:s.status==="dirty"?(t.dirty(),Br(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?F:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new sr({in:e,out:t,typeName:N.ZodPipeline})}}class tr extends W{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Ue(s)&&(s.value=Object.freeze(s.value)),s);return ze(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}tr.create=(i,e)=>new tr({innerType:i,typeName:N.ZodReadonly,...G(e)});function bn(i,e={},t){return i?Ee.create().superRefine((r,s)=>{var n,o;if(!i(r)){const a=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,h=(o=(n=a.fatal)!==null&&n!==void 0?n:t)!==null&&o!==void 0?o:!0,c=typeof a=="string"?{message:a}:a;s.addIssue({code:"custom",...c,fatal:h})}}):Ee.create()}const ch={object:et.lazycreate};var N;(function(i){i.ZodString="ZodString",i.ZodNumber="ZodNumber",i.ZodNaN="ZodNaN",i.ZodBigInt="ZodBigInt",i.ZodBoolean="ZodBoolean",i.ZodDate="ZodDate",i.ZodSymbol="ZodSymbol",i.ZodUndefined="ZodUndefined",i.ZodNull="ZodNull",i.ZodAny="ZodAny",i.ZodUnknown="ZodUnknown",i.ZodNever="ZodNever",i.ZodVoid="ZodVoid",i.ZodArray="ZodArray",i.ZodObject="ZodObject",i.ZodUnion="ZodUnion",i.ZodDiscriminatedUnion="ZodDiscriminatedUnion",i.ZodIntersection="ZodIntersection",i.ZodTuple="ZodTuple",i.ZodRecord="ZodRecord",i.ZodMap="ZodMap",i.ZodSet="ZodSet",i.ZodFunction="ZodFunction",i.ZodLazy="ZodLazy",i.ZodLiteral="ZodLiteral",i.ZodEnum="ZodEnum",i.ZodEffects="ZodEffects",i.ZodNativeEnum="ZodNativeEnum",i.ZodOptional="ZodOptional",i.ZodNullable="ZodNullable",i.ZodDefault="ZodDefault",i.ZodCatch="ZodCatch",i.ZodPromise="ZodPromise",i.ZodBranded="ZodBranded",i.ZodPipeline="ZodPipeline",i.ZodReadonly="ZodReadonly"})(N||(N={}));const lh=(i,e={message:`Input not instance of ${i.name}`})=>bn(t=>t instanceof i,e),Mn=Ct.create,En=Qt.create,uh=Vr.create,dh=te.create,_n=We.create,ph=ae.create,fh=zr.create,mh=Ze.create,gh=Ve.create,yh=Ee.create,vh=ne.create,wh=Ht.create,xh=Wr.create,bh=jt.create,Mh=et.create,Eh=et.strictCreate,_h=qe.create,Th=ii.create,Ph=$e.create,Ih=Nt.create,Rh=Xe.create,Sh=Zr.create,Ah=he.create,Ch=xe.create,kh=He.create,jh=Ye.create,Lh=ee.create,Oh=Ke.create,Dh=_e.create,Os=Lt.create,Nh=Ot.create,Fh=re.create,Gh=Lt.createWithPreprocess,Bh=sr.create,Uh=()=>Mn().optional(),zh=()=>En().optional(),Wh=()=>_n().optional(),Zh={string:i=>Ct.create({...i,coerce:!0}),number:i=>Qt.create({...i,coerce:!0}),boolean:i=>We.create({...i,coerce:!0}),bigint:i=>te.create({...i,coerce:!0}),date:i=>ae.create({...i,coerce:!0})},Vh=F;var v=Object.freeze({__proto__:null,defaultErrorMap:Me,setErrorMap:Va,getErrorMap:Fr,makeIssue:Gr,EMPTY_PATH:qa,addIssueToContext:L,ParseStatus:pt,INVALID:F,DIRTY:Br,OK:yt,isAborted:Gi,isDirty:Bi,isValid:Ue,isAsync:ze,get util(){return H},get objectUtil(){return Fi},ZodParsedType:O,getParsedType:Jt,ZodType:W,datetimeRegex:wn,ZodString:Ct,ZodNumber:Qt,ZodBigInt:te,ZodBoolean:We,ZodDate:ae,ZodSymbol:zr,ZodUndefined:Ze,ZodNull:Ve,ZodAny:Ee,ZodUnknown:ne,ZodNever:Ht,ZodVoid:Wr,ZodArray:jt,ZodObject:et,ZodUnion:qe,ZodDiscriminatedUnion:ii,ZodIntersection:$e,ZodTuple:Nt,ZodRecord:Xe,ZodMap:Zr,ZodSet:he,ZodFunction:xe,ZodLazy:He,ZodLiteral:Ye,ZodEnum:ee,ZodNativeEnum:Ke,ZodPromise:_e,ZodEffects:Lt,ZodTransformer:Lt,ZodOptional:Ot,ZodNullable:re,ZodDefault:Je,ZodCatch:Qe,ZodNaN:Vr,BRAND:hh,ZodBranded:Qi,ZodPipeline:sr,ZodReadonly:tr,custom:bn,Schema:W,ZodSchema:W,late:ch,get ZodFirstPartyTypeKind(){return N},coerce:Zh,any:yh,array:bh,bigint:dh,boolean:_n,date:ph,discriminatedUnion:Th,effect:Os,enum:Lh,function:Ch,instanceof:lh,intersection:Ph,lazy:kh,literal:jh,map:Sh,nan:uh,nativeEnum:Oh,never:wh,null:gh,nullable:Fh,number:En,object:Mh,oboolean:Wh,onumber:zh,optional:Nh,ostring:Uh,pipeline:Bh,preprocess:Gh,promise:Dh,record:Rh,set:Ah,strictObject:Eh,string:Mn,symbol:fh,transformer:Os,tuple:Ih,undefined:mh,union:_h,unknown:vh,void:xh,NEVER:Vh,ZodIssueCode:C,quotelessJson:Za,ZodError:Mt});const si=/^https?:\/\/library.stanford.edu\/iiif\/image-api\/1.1\/compliance.html#level(?<level>[012])$/,Tn=v.string().regex(si),qh=Tn,qr="http://library.stanford.edu/iiif/image-api/1.1/context.json",Pn="http://iiif.io/api/image/1/context.json",In=v.literal(qr),Rn=v.object({"@context":In,"@id":v.string().url(),profile:Tn.optional(),width:v.number().int(),height:v.number().int(),scale_factors:v.number().array().optional(),tile_width:v.number().optional(),tile_height:v.number().optional()}),Sn=v.object({width:v.number().int(),height:v.number().int()}),An=v.object({width:v.number().int(),height:v.number().int().optional(),scaleFactors:v.array(v.number().int())}),$h=["ImageService1","ImageService2","ImageService3"],Cn=v.enum($h),ni=/^https?:\/\/iiif.io\/api\/image\/2.*level(?<level>[012])(.json)?$/,Ds=v.string().regex(ni),Xh=v.object({formats:v.string().array().optional(),maxArea:v.number().int().optional(),maxHeight:v.number().int().optional(),maxWidth:v.number().int().optional(),qualities:v.string().array().optional(),supports:v.string().array().optional()}),$r=Ds.or(v.array(v.union([Ds,Xh,v.any()]))),Xr="http://iiif.io/api/image/2/context.json",kn=v.literal(Xr).or(v.literal("https://iiif.io/api/image/2/context.json")),ts=v.object({"@id":v.string().url(),"@type":v.literal("iiif:Image").optional(),"@context":kn,protocol:v.literal("http://iiif.io/api/image"),width:v.number().int(),height:v.number().int(),profile:$r,sizes:Sn.array().optional(),tiles:An.array().optional()}),Hh=["level0","level1","level2"],jn=v.enum(Hh),es=v.object({id:v.string().url(),type:v.literal("ImageService3"),protocol:v.literal("http://iiif.io/api/image"),profile:jn,width:v.number().int(),height:v.number().int(),maxWidth:v.number().int().optional(),maxHeight:v.number().int().optional(),maxArea:v.number().int().optional(),sizes:Sn.array().optional(),tiles:An.array().optional(),extraFeatures:v.string().array().optional()}),Yh=v.object({"@id":v.string().url(),"@type":Cn.optional(),profile:qh.or($r).or(jn),width:v.number().int().optional(),height:v.number().int().optional(),"@context":In.or(v.literal("http://iiif.io/api/image/1/context.json")).or(kn).optional()}),Kh=["level0","level1","level2"],Jh=v.object({id:v.string().url(),type:v.literal("ImageService2"),profile:$r}).or(v.object({"@id":v.string().url(),"@type":v.literal("ImageService2"),profile:$r})),Qh=v.object({id:v.string().url(),type:Cn,profile:v.enum(Kh)}),tc=v.union([Jh,Qh]),Ln=Yh.or(tc),Ns=v.string().or(v.number()).or(v.boolean()),On=Ns.or(Ns.array()),Fs=v.object({"@language":v.string().optional(),"@value":On}),ce=On.or(Fs).or(Fs.array()),ec=v.union([v.any(),v.object({label:ce.optional(),value:ce.optional()})]).transform(i=>{if(i&&typeof i=="object"&&"label"in i&&"value"in i)return i}),Dn=ec.array(),rc=v.object({width:v.number().int().optional(),height:v.number().int().optional(),service:Ln}),ic=v.object({resource:rc}),Nn=v.object({"@id":v.string().url(),"@type":v.literal("sc:Canvas"),width:v.number().int(),height:v.number().int(),images:ic.array().length(1),label:ce.optional(),metadata:Dn.optional()}),sc=v.object({canvases:Nn.array().nonempty()}),Fn=v.object({"@id":v.string().url(),"@type":v.literal("sc:Manifest"),sequences:sc.array().length(1),label:ce.optional(),description:ce.optional(),metadata:Dn.optional()}),Gs=v.lazy(()=>v.object({"@id":v.string().url(),"@type":v.literal("sc:Manifest"),label:ce.optional()})),zi=v.lazy(()=>v.object({"@id":v.string().url(),"@type":v.literal("sc:Collection"),label:ce.optional(),manifests:Gs.array().optional(),collections:zi.array().optional(),members:Gs.or(zi).array().optional()})),nc=v.string().or(v.number()).or(v.boolean()),le=v.record(v.string(),nc.array()),oc=v.union([v.any(),v.object({label:le.optional(),value:le.optional()})]).transform(i=>{if(i&&typeof i=="object"&&"label"in i&&"value"in i)return i}),Gn=oc.array(),Bs=v.object({type:v.literal("Image"),width:v.number().int().optional(),height:v.number().int().optional(),service:Ln.array()}),ac=v.object({type:v.literal("Annotation"),body:Bs.or(Bs.array().length(1))}),hc=v.object({type:v.literal("AnnotationPage"),items:ac.array().length(1)}),Bn=v.object({id:v.string().url(),type:v.literal("Canvas"),width:v.number().int(),height:v.number().int(),items:hc.array().length(1),label:le.optional(),metadata:Gn.optional()}),Un=v.object({id:v.string().url(),type:v.literal("Manifest"),items:Bn.array().nonempty(),label:le.optional(),description:le.optional(),metadata:Gn.optional()}),cc=v.lazy(()=>v.object({id:v.string().url(),type:v.literal("Manifest"),label:le.optional()})),zn=v.lazy(()=>v.object({id:v.string().url(),type:v.literal("Collection"),label:le.optional(),items:cc.or(zn).array()})),Wn=Rn.or(ts).or(es);Nn.or(Bn);const lc=Fn.or(Un);zi.or(zn);Fn.or(ts);Un.or(es);lc.or(Wn);function Zn({width:i,height:e},t,r,s){const n=r*t.originalWidth,o=s*t.originalHeight,a=r*t.originalWidth+t.width*t.scaleFactor>i?i-r*t.originalWidth:t.width*t.scaleFactor,h=s*t.originalHeight+t.height*t.scaleFactor>e?e-s*t.originalHeight:t.height*t.scaleFactor;let c=t.width,l=t.height;return n+t.width*t.scaleFactor>i&&(c=Math.floor((i-n+t.scaleFactor-1)/t.scaleFactor)),o+t.height*t.scaleFactor>e&&(l=Math.floor((e-o+t.scaleFactor-1)/t.scaleFactor)),{region:{x:n,y:o,width:a,height:h},size:{width:c,height:l}}}function uc({width:i,height:e},t=768){const r=Math.max(i,e)/t,s=Math.ceil(Math.log(r)/Math.log(2));return{scaleFactors:Array.from({length:s},(n,o)=>2**o),width:t}}function dc({width:i,height:e},t,r){const s=t.height||t.width,n=t.width*r,o=s*r;return{scaleFactor:r,width:t.width,height:s,originalWidth:n,originalHeight:o,columns:Math.ceil(i/n),rows:Math.ceil(e/o)}}function pc(i,e){return e.map(t=>t.scaleFactors.map(r=>dc(i,t,r))).flat()}function fc(i){return!!i.some(e=>e.width&&e.scaleFactors&&e.scaleFactors.length)}function mc(i,e,t){if(!e||!fc(e))if(t)e=[uc(i)];else throw new Error("Image does not support tiles or custom regions and sizes.");return pc(i,e)}function gc(i,e,t="cover"){if(t==="cover"||t==="contain"){const r=e.width/i.width,s=e.height/i.height,n=t==="cover"?Math.max(r,s):Math.min(r,s),o=i.width*n,a=i.height*n;return{width:o,height:a}}else throw new Error('Mode must be either "cover" or "contain"')}const yc=.8,vc=1.5;function Vn(i,e,t="cover",{sizes:r,tileZoomLevels:s,supportsAnyRegionAndSize:n,maxWidth:o,maxHeight:a,maxArea:h}){let{width:c,height:l}=gc(i,e,t);if(o&&c>o&&(l=l/c*o,c=o),a&&l>a&&(c=c/l*a,l=a),h&&c*l>h){const m=l/c,g=Math.floor(Math.sqrt(h/m))*m;c=Math.floor(g)/m,l=c*m}const u=i.width/i.height;if(c=Math.floor(c),l=Math.round(c/u),r){let m;for(const g of r){const y=g.width/c;if(y>=yc&&y<=vc){m=g;break}}if(m)return{size:m}}if(n)return{size:{width:Math.round(c),height:Math.round(l)}};if(s){const m=i.width/c,g=s.map(({scaleFactor:R},d)=>({index:d,scaleFactor:R,diff:Math.abs(R-m)})).sort((R,d)=>R.diff-d.diff),y=s[g[0].index],_=Math.ceil(i.width/(y.scaleFactor*s[0].width)),I=Math.ceil(i.height/(y.scaleFactor*s[0].height)),w=[];for(let R=0;R<I;R++){const d=[];for(let f=0;f<_;f++){const x=Zn(i,y,f,R);d.push(x)}w.push(d)}return w}throw new Error("Unable to create thumbnail")}const qn=["regionByPx","sizeByWh"];function wc(i){const e=i.match(si);if(e&&e.groups)return parseInt(e.groups.level)}function Us(i){const e=i.match(ni);if(e&&e.groups)return parseInt(e.groups.level)}function xc(i){return{maxWidth:i==null?void 0:i.maxWidth,maxHeight:i==null?void 0:i.maxHeight,maxArea:i==null?void 0:i.maxArea,supportsAnyRegionAndSize:qn.every(e=>{var t;return(i==null?void 0:i.supports)&&((t=i==null?void 0:i.supports)==null?void 0:t.includes(e))})}}function bc(i){if("type"in i&&i.type==="ImageService3")return 3;if("type"in i&&i.type==="ImageService2"||"@type"in i&&i["@type"]==="ImageService2"||"@context"in i&&i["@context"]===Xr)return 2;if("@context"in i&&(i["@context"]===qr||i["@context"]===Pn))return 1;if("profile"in i){let e;return Array.isArray(i.profile)?e=i.profile[0]:e=i.profile,e.match(si)?1:e.match(ni)?2:3}else throw new Error("Unsupported IIIF Image Service")}function Wi(i){if("type"in i||"@type"in i){const e=i.profile;let t=!1;return e==="level0"||typeof e=="string"&&e.endsWith("level0.json")?"extraFeatures"in i&&(t=qn.every(r=>i.extraFeatures&&i.extraFeatures.includes(r))):t=!0,{maxWidth:"maxWidth"in i?i.maxWidth:void 0,maxHeight:"maxHeight"in i?i.maxHeight:void 0,maxArea:"maxArea"in i?i.maxArea:void 0,supportsAnyRegionAndSize:t}}else if(Array.isArray(i.profile)){let e=!1,t=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return i.profile.forEach(n=>{if(typeof n=="string"){const o=Us(n);o&&(e=e||o>=1)}else{const{maxWidth:o,maxHeight:a,maxArea:h,supportsAnyRegionAndSize:c}=xc(n);o!==void 0&&(r=Math.max(o,r)),a!==void 0&&(t=Math.max(a,t)),h!==void 0&&(s=Math.max(h,s)),e=e||c}}),{maxWidth:r>=0?r:void 0,maxHeight:t>=0?t:void 0,maxArea:s>=0?s:void 0,supportsAnyRegionAndSize:e}}else if("profile"in i&&i.profile){const e=wc(i.profile),t=Us(i.profile);return e?{supportsAnyRegionAndSize:e>=1}:t?{supportsAnyRegionAndSize:t>=1}:{supportsAnyRegionAndSize:!1}}else throw new Error("Invalid Image")}const Mc="image";class Ec{constructor(e,t){M(this,"embedded",!0);M(this,"uri");M(this,"type",Mc);M(this,"maxWidth");M(this,"maxHeight");M(this,"maxArea");M(this,"supportsAnyRegionAndSize");M(this,"width");M(this,"height");M(this,"majorVersion");if(t){const r=e;let s,n;if(Array.isArray(r.service)?r.service.forEach(o=>{try{const a=bc(o);(!n||a>n)&&(n=a,s=o)}catch{}}):s=r.service,!s)throw new Error("Unsupported IIIF Image Service");if("@id"in s)this.uri=s["@id"];else if("id"in s)this.uri=s.id;else throw new Error("Unsupported IIIF Image Service");if("type"in s&&s.type==="ImageService3")this.majorVersion=3;else if("type"in s&&s.type==="ImageService2"||"@type"in s&&s["@type"]==="ImageService2"||"@context"in s&&s["@context"]===Xr)this.majorVersion=2;else if("@context"in s&&(s["@context"]===qr||s["@context"]===Pn))this.majorVersion=1;else if("profile"in s){let o;Array.isArray(s.profile)?o=s.profile[0]:o=s.profile,o.match(si)?this.majorVersion=1:o.match(ni)?this.majorVersion=2:this.majorVersion=3}else throw new Error("Unsupported IIIF Image Service");if("profile"in s){const o=Wi(s);this.supportsAnyRegionAndSize=o.supportsAnyRegionAndSize,this.maxWidth=o.maxWidth,this.maxHeight=o.maxHeight,this.maxArea=o.maxArea}else this.supportsAnyRegionAndSize=!1}else{if("@id"in e)this.uri=e["@id"];else if("id"in e)this.uri=e.id;else throw new Error("Unsupported IIIF Image");if("type"in e&&e.type==="ImageService3")this.majorVersion=3;else if("@type"in e&&e["@type"]==="iiif:Image"||"@context"in e&&e["@context"]===Xr)this.majorVersion=2;else if("@context"in e&&e["@context"]===qr)this.majorVersion=1;else throw new Error("Unsupported IIIF Image");if("profile"in e){const r=Wi(e);this.supportsAnyRegionAndSize=r.supportsAnyRegionAndSize,this.maxWidth=r.maxWidth,this.maxHeight=r.maxHeight,this.maxArea=r.maxArea}else this.supportsAnyRegionAndSize=!1}if(e.width!==void 0)this.width=e.width;else if(t)this.width=t.width;else throw new Error("Width not present on either Canvas or Image Resource");if(e.height!==void 0)this.height=e.height;else if(t)this.height=t.height;else throw new Error("Height not present on either Canvas or Image Resource")}getImageUrl(e){const{region:t,size:r}=e;let s,n,o,a,h;t?(h=`${t.x},${t.y},${t.width},${t.height}`,o=t.height,a=t.width):(h="full",o=this.height,a=this.width);let c;if(r){s=Math.round(r.width),n=Math.round(r.height);const m=String(s);let g=String(n);const y=a/o,_=n*y/y;n===Math.round(_)&&(g=""),c=`${m},${g}`}else s=this.width,n=this.height,c=this.majorVersion===2?"full":"max";const l=s*n;if(this.maxWidth!==void 0&&s>this.maxWidth)throw new Error(`Width of requested image is too large: ${s} > ${this.maxWidth}`);if(this.maxHeight!==void 0&&n>this.maxHeight)throw new Error(`Height of requested image is too large: ${n} > ${this.maxHeight}`);if(this.maxArea!==void 0&&l>this.maxArea)throw new Error(`Area of requested image is too large: ${l} > ${this.maxArea}`);const u=this.majorVersion===1?"native":"default";return`${this.uri}/${h}/${c}/0/${u}.jpg`}getThumbnail(e,t="cover"){return Vn({width:this.width,height:this.height},e,t,{supportsAnyRegionAndSize:this.supportsAnyRegionAndSize,maxWidth:this.maxWidth,maxHeight:this.maxHeight,maxArea:this.maxArea})}}class rs extends Ec{constructor(t){super(t);M(this,"tileZoomLevels");M(this,"sizes");M(this,"embedded",!1);const r=Wi(t);let s;"tiles"in t&&(s=t.tiles),this.tileZoomLevels=mc({width:this.width,height:this.height},s,r.supportsAnyRegionAndSize),"sizes"in t&&(this.sizes=t.sizes)}static parse(t,r=null){let s;return r===1?s=Rn.parse(t):r===2?s=ts.parse(t):r===3?s=es.parse(t):s=Wn.parse(t),new rs(s)}getIiifTile(t,r,s){return Zn({width:this.width,height:this.height},t,r,s)}getThumbnail(t,r="cover"){return Vn({width:this.width,height:this.height},t,r,{supportsAnyRegionAndSize:this.supportsAnyRegionAndSize,sizes:this.sizes,tileZoomLevels:this.tileZoomLevels,maxWidth:this.maxWidth,maxHeight:this.maxHeight,maxArea:this.maxArea})}}const zs=v.record(v.string(),v.string().array());v.object({label:zs.optional(),value:zs.optional()});var vt=63710088e-1,$n={centimeters:vt*100,centimetres:vt*100,degrees:vt/111325,feet:vt*3.28084,inches:vt*39.37,kilometers:vt/1e3,kilometres:vt/1e3,meters:vt,metres:vt,miles:vt/1609.344,millimeters:vt*1e3,millimetres:vt*1e3,nauticalmiles:vt/1852,radians:1,yards:vt*1.0936};function _c(i,e,t){t===void 0&&(t={});var r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=i,r}function Tc(i,e,t){if(t===void 0&&(t={}),!i)throw new Error("coordinates is required");if(!Array.isArray(i))throw new Error("coordinates must be an Array");if(i.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ws(i[0])||!Ws(i[1]))throw new Error("coordinates must contain numbers");var r={type:"Point",coordinates:i};return _c(r,e,t)}function Pc(i,e){e===void 0&&(e="kilometers");var t=$n[e];if(!t)throw new Error(e+" units is invalid");return i*t}function Ic(i,e){e===void 0&&(e="kilometers");var t=$n[e];if(!t)throw new Error(e+" units is invalid");return i/t}function Zi(i){var e=i%(2*Math.PI);return e*180/Math.PI}function kt(i){var e=i%360;return e*Math.PI/180}function Ws(i){return!isNaN(i)&&i!==null&&!Array.isArray(i)}function Te(i){if(!i)throw new Error("coord is required");if(!Array.isArray(i)){if(i.type==="Feature"&&i.geometry!==null&&i.geometry.type==="Point")return i.geometry.coordinates;if(i.type==="Point")return i.coordinates}if(Array.isArray(i)&&i.length>=2&&!Array.isArray(i[0])&&!Array.isArray(i[1]))return i;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Rc(i){return i.type==="Feature"?i.geometry:i}function Xn(i,e,t){if(t===void 0&&(t={}),t.final===!0)return Sc(i,e);var r=Te(i),s=Te(e),n=kt(r[0]),o=kt(s[0]),a=kt(r[1]),h=kt(s[1]),c=Math.sin(o-n)*Math.cos(h),l=Math.cos(a)*Math.sin(h)-Math.sin(a)*Math.cos(h)*Math.cos(o-n);return Zi(Math.atan2(c,l))}function Sc(i,e){var t=Xn(e,i);return t=(t+180)%360,t}function Ac(i,e,t,r){r===void 0&&(r={});var s=Te(i),n=kt(s[0]),o=kt(s[1]),a=kt(t),h=Ic(e,r.units),c=Math.asin(Math.sin(o)*Math.cos(h)+Math.cos(o)*Math.sin(h)*Math.cos(a)),l=n+Math.atan2(Math.sin(a)*Math.sin(h)*Math.cos(o),Math.cos(h)-Math.sin(o)*Math.sin(c)),u=Zi(l),m=Zi(c);return Tc([u,m],r.properties)}function is(i,e,t){t===void 0&&(t={});var r=Te(i),s=Te(e),n=kt(s[1]-r[1]),o=kt(s[0]-r[0]),a=kt(r[1]),h=kt(s[1]),c=Math.pow(Math.sin(n/2),2)+Math.pow(Math.sin(o/2),2)*Math.cos(a)*Math.cos(h);return Pc(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),t.units)}function Hr(i,e){var t=is(i,e),r=Xn(i,e),s=Ac(i,t/2,r);return s}function Hn(i){if(i.__esModule)return i;var e=i.default;if(typeof e=="function"){var t=function r(){return this instanceof r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(i).forEach(function(r){var s=Object.getOwnPropertyDescriptor(i,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return i[r]}})}),t}var q={};const Cc=Object.prototype.toString;function er(i){const e=Cc.call(i);return e.endsWith("Array]")&&!e.includes("Big")}const kc=Object.freeze(Object.defineProperty({__proto__:null,isAnyArray:er},Symbol.toStringTag,{value:"Module"})),jc=Hn(kc);function Lc(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!er(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,s=e.toIndex,n=s===void 0?i.length:s;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=r||n>i.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=i[r],a=r+1;a<n;a++)i[a]>o&&(o=i[a]);return o}function Oc(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!er(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var t=e.fromIndex,r=t===void 0?0:t,s=e.toIndex,n=s===void 0?i.length:s;if(r<0||r>=i.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=r||n>i.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=i[r],a=r+1;a<n;a++)i[a]<o&&(o=i[a]);return o}function Dc(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(er(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var t;if(e.output!==void 0){if(!er(e.output))throw new TypeError("output option must be an array if specified");t=e.output}else t=new Array(i.length);var r=Oc(i),s=Lc(i);if(r===s)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var n=e.min,o=n===void 0?e.autoMinMax?r:0:n,a=e.max,h=a===void 0?e.autoMinMax?s:1:a;if(o>=h)throw new RangeError("min option must be smaller than max option");for(var c=(h-o)/(s-r),l=0;l<i.length;l++)t[l]=(i[l]-r)*c+o;return t}const Nc=Object.freeze(Object.defineProperty({__proto__:null,default:Dc},Symbol.toStringTag,{value:"Module"})),Fc=Hn(Nc);Object.defineProperty(q,"__esModule",{value:!0});var wt=jc,Zs=Fc;const xr=" ".repeat(2),Yn=" ".repeat(4);function Gc(){return Kn(this)}function Kn(i,e={}){const{maxRows:t=15,maxColumns:r=10,maxNumSize:s=8,padMinus:n="auto"}=e;return`${i.constructor.name} {
9
+ ${xr}[
10
+ ${Yn}${Bc(i,t,r,s,n)}
11
+ ${xr}]
12
+ ${xr}rows: ${i.rows}
13
+ ${xr}columns: ${i.columns}
14
+ }`}function Bc(i,e,t,r,s){const{rows:n,columns:o}=i,a=Math.min(n,e),h=Math.min(o,t),c=[];if(s==="auto"){s=!1;t:for(let l=0;l<a;l++)for(let u=0;u<h;u++)if(i.get(l,u)<0){s=!0;break t}}for(let l=0;l<a;l++){let u=[];for(let m=0;m<h;m++)u.push(Uc(i.get(l,m),r,s));c.push(`${u.join(" ")}`)}return h!==o&&(c[c.length-1]+=` ... ${o-t} more columns`),a!==n&&c.push(`... ${n-e} more rows`),c.join(`
15
+ ${Yn}`)}function Uc(i,e,t){return(i>=0&&t?` ${Vs(i,e-1)}`:Vs(i,e)).padEnd(e)}function Vs(i,e){let t=i.toString();if(t.length<=e)return t;let r=i.toFixed(e);if(r.length>e&&(r=i.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let s=i.toExponential(e);return s.length>e&&(s=i.toExponential(Math.max(0,e-(s.length-e)))),s.slice(0)}function zc(i,e){i.prototype.add=function(t){return typeof t=="number"?this.addS(t):this.addM(t)},i.prototype.addS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)+t);return this},i.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)+t.get(r,s));return this},i.add=function(t,r){return new e(t).add(r)},i.prototype.sub=function(t){return typeof t=="number"?this.subS(t):this.subM(t)},i.prototype.subS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)-t);return this},i.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)-t.get(r,s));return this},i.sub=function(t,r){return new e(t).sub(r)},i.prototype.subtract=i.prototype.sub,i.prototype.subtractS=i.prototype.subS,i.prototype.subtractM=i.prototype.subM,i.subtract=i.sub,i.prototype.mul=function(t){return typeof t=="number"?this.mulS(t):this.mulM(t)},i.prototype.mulS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)*t);return this},i.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)*t.get(r,s));return this},i.mul=function(t,r){return new e(t).mul(r)},i.prototype.multiply=i.prototype.mul,i.prototype.multiplyS=i.prototype.mulS,i.prototype.multiplyM=i.prototype.mulM,i.multiply=i.mul,i.prototype.div=function(t){return typeof t=="number"?this.divS(t):this.divM(t)},i.prototype.divS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)/t);return this},i.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)/t.get(r,s));return this},i.div=function(t,r){return new e(t).div(r)},i.prototype.divide=i.prototype.div,i.prototype.divideS=i.prototype.divS,i.prototype.divideM=i.prototype.divM,i.divide=i.div,i.prototype.mod=function(t){return typeof t=="number"?this.modS(t):this.modM(t)},i.prototype.modS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)%t);return this},i.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)%t.get(r,s));return this},i.mod=function(t,r){return new e(t).mod(r)},i.prototype.modulus=i.prototype.mod,i.prototype.modulusS=i.prototype.modS,i.prototype.modulusM=i.prototype.modM,i.modulus=i.mod,i.prototype.and=function(t){return typeof t=="number"?this.andS(t):this.andM(t)},i.prototype.andS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)&t);return this},i.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)&t.get(r,s));return this},i.and=function(t,r){return new e(t).and(r)},i.prototype.or=function(t){return typeof t=="number"?this.orS(t):this.orM(t)},i.prototype.orS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)|t);return this},i.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)|t.get(r,s));return this},i.or=function(t,r){return new e(t).or(r)},i.prototype.xor=function(t){return typeof t=="number"?this.xorS(t):this.xorM(t)},i.prototype.xorS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)^t);return this},i.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)^t.get(r,s));return this},i.xor=function(t,r){return new e(t).xor(r)},i.prototype.leftShift=function(t){return typeof t=="number"?this.leftShiftS(t):this.leftShiftM(t)},i.prototype.leftShiftS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)<<t);return this},i.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)<<t.get(r,s));return this},i.leftShift=function(t,r){return new e(t).leftShift(r)},i.prototype.signPropagatingRightShift=function(t){return typeof t=="number"?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},i.prototype.signPropagatingRightShiftS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)>>t);return this},i.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)>>t.get(r,s));return this},i.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},i.prototype.rightShift=function(t){return typeof t=="number"?this.rightShiftS(t):this.rightShiftM(t)},i.prototype.rightShiftS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)>>>t);return this},i.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,this.get(r,s)>>>t.get(r,s));return this},i.rightShift=function(t,r){return new e(t).rightShift(r)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,~this.get(t,r));return this},i.not=function(t){return new e(t).not()},i.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.abs(this.get(t,r)));return this},i.abs=function(t){return new e(t).abs()},i.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.acos(this.get(t,r)));return this},i.acos=function(t){return new e(t).acos()},i.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.acosh(this.get(t,r)));return this},i.acosh=function(t){return new e(t).acosh()},i.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.asin(this.get(t,r)));return this},i.asin=function(t){return new e(t).asin()},i.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.asinh(this.get(t,r)));return this},i.asinh=function(t){return new e(t).asinh()},i.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.atan(this.get(t,r)));return this},i.atan=function(t){return new e(t).atan()},i.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.atanh(this.get(t,r)));return this},i.atanh=function(t){return new e(t).atanh()},i.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.cbrt(this.get(t,r)));return this},i.cbrt=function(t){return new e(t).cbrt()},i.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.ceil(this.get(t,r)));return this},i.ceil=function(t){return new e(t).ceil()},i.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.clz32(this.get(t,r)));return this},i.clz32=function(t){return new e(t).clz32()},i.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.cos(this.get(t,r)));return this},i.cos=function(t){return new e(t).cos()},i.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.cosh(this.get(t,r)));return this},i.cosh=function(t){return new e(t).cosh()},i.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.exp(this.get(t,r)));return this},i.exp=function(t){return new e(t).exp()},i.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.expm1(this.get(t,r)));return this},i.expm1=function(t){return new e(t).expm1()},i.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.floor(this.get(t,r)));return this},i.floor=function(t){return new e(t).floor()},i.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.fround(this.get(t,r)));return this},i.fround=function(t){return new e(t).fround()},i.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.log(this.get(t,r)));return this},i.log=function(t){return new e(t).log()},i.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.log1p(this.get(t,r)));return this},i.log1p=function(t){return new e(t).log1p()},i.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.log10(this.get(t,r)));return this},i.log10=function(t){return new e(t).log10()},i.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.log2(this.get(t,r)));return this},i.log2=function(t){return new e(t).log2()},i.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.round(this.get(t,r)));return this},i.round=function(t){return new e(t).round()},i.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.sign(this.get(t,r)));return this},i.sign=function(t){return new e(t).sign()},i.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.sin(this.get(t,r)));return this},i.sin=function(t){return new e(t).sin()},i.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.sinh(this.get(t,r)));return this},i.sinh=function(t){return new e(t).sinh()},i.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.sqrt(this.get(t,r)));return this},i.sqrt=function(t){return new e(t).sqrt()},i.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.tan(this.get(t,r)));return this},i.tan=function(t){return new e(t).tan()},i.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.tanh(this.get(t,r)));return this},i.tanh=function(t){return new e(t).tanh()},i.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,Math.trunc(this.get(t,r)));return this},i.trunc=function(t){return new e(t).trunc()},i.pow=function(t,r){return new e(t).pow(r)},i.prototype.pow=function(t){return typeof t=="number"?this.powS(t):this.powM(t)},i.prototype.powS=function(t){for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,Math.pow(this.get(r,s),t));return this},i.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.set(r,s,Math.pow(this.get(r,s),t.get(r,s)));return this}}function Tt(i,e,t){let r=t?i.rows:i.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function Pt(i,e,t){let r=t?i.columns:i.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function ge(i,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function ye(i,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function ss(i,e){if(!wt.isAnyArray(e))throw new TypeError("row indices must be an array");for(let t=0;t<e.length;t++)if(e[t]<0||e[t]>=i.rows)throw new RangeError("row indices are out of range")}function ns(i,e){if(!wt.isAnyArray(e))throw new TypeError("column indices must be an array");for(let t=0;t<e.length;t++)if(e[t]<0||e[t]>=i.columns)throw new RangeError("column indices are out of range")}function Vi(i,e,t,r,s){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(br("startRow",e),br("endRow",t),br("startColumn",r),br("endColumn",s),e>t||r>s||e<0||e>=i.rows||t<0||t>=i.rows||r<0||r>=i.columns||s<0||s>=i.columns)throw new RangeError("Submatrix indices are out of range")}function oi(i,e=0){let t=[];for(let r=0;r<i;r++)t.push(e);return t}function br(i,e){if(typeof e!="number")throw new TypeError(`${i} must be a number`)}function ue(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function Wc(i){let e=oi(i.rows);for(let t=0;t<i.rows;++t)for(let r=0;r<i.columns;++r)e[t]+=i.get(t,r);return e}function Zc(i){let e=oi(i.columns);for(let t=0;t<i.rows;++t)for(let r=0;r<i.columns;++r)e[r]+=i.get(t,r);return e}function Vc(i){let e=0;for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)e+=i.get(t,r);return e}function qc(i){let e=oi(i.rows,1);for(let t=0;t<i.rows;++t)for(let r=0;r<i.columns;++r)e[t]*=i.get(t,r);return e}function $c(i){let e=oi(i.columns,1);for(let t=0;t<i.rows;++t)for(let r=0;r<i.columns;++r)e[r]*=i.get(t,r);return e}function Xc(i){let e=1;for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)e*=i.get(t,r);return e}function Hc(i,e,t){const r=i.rows,s=i.columns,n=[];for(let o=0;o<r;o++){let a=0,h=0,c=0;for(let l=0;l<s;l++)c=i.get(o,l)-t[o],a+=c,h+=c*c;e?n.push((h-a*a/s)/(s-1)):n.push((h-a*a/s)/s)}return n}function Yc(i,e,t){const r=i.rows,s=i.columns,n=[];for(let o=0;o<s;o++){let a=0,h=0,c=0;for(let l=0;l<r;l++)c=i.get(l,o)-t[o],a+=c,h+=c*c;e?n.push((h-a*a/r)/(r-1)):n.push((h-a*a/r)/r)}return n}function Kc(i,e,t){const r=i.rows,s=i.columns,n=r*s;let o=0,a=0,h=0;for(let c=0;c<r;c++)for(let l=0;l<s;l++)h=i.get(c,l)-t,o+=h,a+=h*h;return e?(a-o*o/n)/(n-1):(a-o*o/n)/n}function Jc(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)-e[t])}function Qc(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)-e[r])}function tl(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)-e)}function el(i){const e=[];for(let t=0;t<i.rows;t++){let r=0;for(let s=0;s<i.columns;s++)r+=Math.pow(i.get(t,s),2)/(i.columns-1);e.push(Math.sqrt(r))}return e}function rl(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)/e[t])}function il(i){const e=[];for(let t=0;t<i.columns;t++){let r=0;for(let s=0;s<i.rows;s++)r+=Math.pow(i.get(s,t),2)/(i.rows-1);e.push(Math.sqrt(r))}return e}function sl(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)/e[r])}function nl(i){const e=i.size-1;let t=0;for(let r=0;r<i.columns;r++)for(let s=0;s<i.rows;s++)t+=Math.pow(i.get(s,r),2)/e;return Math.sqrt(t)}function ol(i,e){for(let t=0;t<i.rows;t++)for(let r=0;r<i.columns;r++)i.set(t,r,i.get(t,r)/e)}let rt=class at{static from1DArray(e,t,r){if(e*t!==r.length)throw new RangeError("data length does not match given dimensions");let s=new j(e,t);for(let n=0;n<e;n++)for(let o=0;o<t;o++)s.set(n,o,r[n*t+o]);return s}static rowVector(e){let t=new j(1,e.length);for(let r=0;r<e.length;r++)t.set(0,r,e[r]);return t}static columnVector(e){let t=new j(e.length,1);for(let r=0;r<e.length;r++)t.set(r,0,e[r]);return t}static zeros(e,t){return new j(e,t)}static ones(e,t){return new j(e,t).fill(1)}static rand(e,t,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{random:s=Math.random}=r;let n=new j(e,t);for(let o=0;o<e;o++)for(let a=0;a<t;a++)n.set(o,a,s());return n}static randInt(e,t,r={}){if(typeof r!="object")throw new TypeError("options must be an object");const{min:s=0,max:n=1e3,random:o=Math.random}=r;if(!Number.isInteger(s))throw new TypeError("min must be an integer");if(!Number.isInteger(n))throw new TypeError("max must be an integer");if(s>=n)throw new RangeError("min must be smaller than max");let a=n-s,h=new j(e,t);for(let c=0;c<e;c++)for(let l=0;l<t;l++){let u=s+Math.round(o()*a);h.set(c,l,u)}return h}static eye(e,t,r){t===void 0&&(t=e),r===void 0&&(r=1);let s=Math.min(e,t),n=this.zeros(e,t);for(let o=0;o<s;o++)n.set(o,o,r);return n}static diag(e,t,r){let s=e.length;t===void 0&&(t=s),r===void 0&&(r=t);let n=Math.min(s,t,r),o=this.zeros(t,r);for(let a=0;a<n;a++)o.set(a,a,e[a]);return o}static min(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let r=e.rows,s=e.columns,n=new j(r,s);for(let o=0;o<r;o++)for(let a=0;a<s;a++)n.set(o,a,Math.min(e.get(o,a),t.get(o,a)));return n}static max(e,t){e=this.checkMatrix(e),t=this.checkMatrix(t);let r=e.rows,s=e.columns,n=new this(r,s);for(let o=0;o<r;o++)for(let a=0;a<s;a++)n.set(o,a,Math.max(e.get(o,a),t.get(o,a)));return n}static checkMatrix(e){return at.isMatrix(e)?e:new j(e)}static isMatrix(e){return e!=null&&e.klass==="Matrix"}get size(){return this.rows*this.columns}apply(e){if(typeof e!="function")throw new TypeError("callback must be a function");for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.call(this,t,r);return this}to1DArray(){let e=[];for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}to2DArray(){let e=[];for(let t=0;t<this.rows;t++){e.push([]);for(let r=0;r<this.columns;r++)e[t].push(this.get(t,r))}return e}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let e=0;e<this.rows;e++)for(let t=0;t<=e;t++)if(this.get(e,t)!==this.get(t,e))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let e=0;e<this.rows;e++)if(this.get(e,e)!==0)return!1;return!0}isEchelonForm(){let e=0,t=0,r=-1,s=!0,n=!1;for(;e<this.rows&&s;){for(t=0,n=!1;t<this.columns&&n===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>r?(n=!0,r=t):(s=!1,n=!0);e++}return s}isReducedEchelonForm(){let e=0,t=0,r=-1,s=!0,n=!1;for(;e<this.rows&&s;){for(t=0,n=!1;t<this.columns&&n===!1;)this.get(e,t)===0?t++:this.get(e,t)===1&&t>r?(n=!0,r=t):(s=!1,n=!0);for(let o=t+1;o<this.rows;o++)this.get(e,o)!==0&&(s=!1);e++}return s}echelonForm(){let e=this.clone(),t=0,r=0;for(;t<e.rows&&r<e.columns;){let s=t;for(let n=t;n<e.rows;n++)e.get(n,r)>e.get(s,r)&&(s=n);if(e.get(s,r)===0)r++;else{e.swapRows(t,s);let n=e.get(t,r);for(let o=r;o<e.columns;o++)e.set(t,o,e.get(t,o)/n);for(let o=t+1;o<e.rows;o++){let a=e.get(o,r)/e.get(t,r);e.set(o,r,0);for(let h=r+1;h<e.columns;h++)e.set(o,h,e.get(o,h)-e.get(t,h)*a)}t++,r++}}return e}reducedEchelonForm(){let e=this.echelonForm(),t=e.columns,r=e.rows,s=r-1;for(;s>=0;)if(e.maxRow(s)===0)s--;else{let n=0,o=!1;for(;n<r&&o===!1;)e.get(s,n)===1?o=!0:n++;for(let a=0;a<s;a++){let h=e.get(a,n);for(let c=n;c<t;c++){let l=e.get(a,c)-h*e.get(s,c);e.set(a,c,l)}}s--}return e}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{rows:t=1,columns:r=1}=e;if(!Number.isInteger(t)||t<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let s=new j(this.rows*t,this.columns*r);for(let n=0;n<t;n++)for(let o=0;o<r;o++)s.setSubMatrix(this,this.rows*n,this.columns*o);return s}fill(e){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,e);return this}neg(){return this.mulS(-1)}getRow(e){Tt(this,e);let t=[];for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}getRowVector(e){return j.rowVector(this.getRow(e))}setRow(e,t){Tt(this,e),t=ge(this,t);for(let r=0;r<this.columns;r++)this.set(e,r,t[r]);return this}swapRows(e,t){Tt(this,e),Tt(this,t);for(let r=0;r<this.columns;r++){let s=this.get(e,r);this.set(e,r,this.get(t,r)),this.set(t,r,s)}return this}getColumn(e){Pt(this,e);let t=[];for(let r=0;r<this.rows;r++)t.push(this.get(r,e));return t}getColumnVector(e){return j.columnVector(this.getColumn(e))}setColumn(e,t){Pt(this,e),t=ye(this,t);for(let r=0;r<this.rows;r++)this.set(r,e,t[r]);return this}swapColumns(e,t){Pt(this,e),Pt(this,t);for(let r=0;r<this.rows;r++){let s=this.get(r,e);this.set(r,e,this.get(r,t)),this.set(r,t,s)}return this}addRowVector(e){e=ge(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)+e[r]);return this}subRowVector(e){e=ge(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)-e[r]);return this}mulRowVector(e){e=ge(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e[r]);return this}divRowVector(e){e=ge(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)/e[r]);return this}addColumnVector(e){e=ye(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)+e[t]);return this}subColumnVector(e){e=ye(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)-e[t]);return this}mulColumnVector(e){e=ye(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e[t]);return this}divColumnVector(e){e=ye(this,e);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)/e[t]);return this}mulRow(e,t){Tt(this,e);for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this}mulColumn(e,t){Pt(this,e);for(let r=0;r<this.rows;r++)this.set(r,e,this.get(r,e)*t);return this}max(e){if(this.isEmpty())return NaN;switch(e){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.get(r,s)>t[r]&&(t[r]=this.get(r,s));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.get(r,s)>t[s]&&(t[s]=this.get(r,s));return t}case void 0:{let t=this.get(0,0);for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.get(r,s)>t&&(t=this.get(r,s));return t}default:throw new Error(`invalid option: ${e}`)}}maxIndex(){ue(this);let e=this.get(0,0),t=[0,0];for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.get(r,s)>e&&(e=this.get(r,s),t[0]=r,t[1]=s);return t}min(e){if(this.isEmpty())return NaN;switch(e){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.get(r,s)<t[r]&&(t[r]=this.get(r,s));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.get(r,s)<t[s]&&(t[s]=this.get(r,s));return t}case void 0:{let t=this.get(0,0);for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.get(r,s)<t&&(t=this.get(r,s));return t}default:throw new Error(`invalid option: ${e}`)}}minIndex(){ue(this);let e=this.get(0,0),t=[0,0];for(let r=0;r<this.rows;r++)for(let s=0;s<this.columns;s++)this.get(r,s)<e&&(e=this.get(r,s),t[0]=r,t[1]=s);return t}maxRow(e){if(Tt(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let r=1;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}maxRowIndex(e){Tt(this,e),ue(this);let t=this.get(e,0),r=[e,0];for(let s=1;s<this.columns;s++)this.get(e,s)>t&&(t=this.get(e,s),r[1]=s);return r}minRow(e){if(Tt(this,e),this.isEmpty())return NaN;let t=this.get(e,0);for(let r=1;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}minRowIndex(e){Tt(this,e),ue(this);let t=this.get(e,0),r=[e,0];for(let s=1;s<this.columns;s++)this.get(e,s)<t&&(t=this.get(e,s),r[1]=s);return r}maxColumn(e){if(Pt(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let r=1;r<this.rows;r++)this.get(r,e)>t&&(t=this.get(r,e));return t}maxColumnIndex(e){Pt(this,e),ue(this);let t=this.get(0,e),r=[0,e];for(let s=1;s<this.rows;s++)this.get(s,e)>t&&(t=this.get(s,e),r[0]=s);return r}minColumn(e){if(Pt(this,e),this.isEmpty())return NaN;let t=this.get(0,e);for(let r=1;r<this.rows;r++)this.get(r,e)<t&&(t=this.get(r,e));return t}minColumnIndex(e){Pt(this,e),ue(this);let t=this.get(0,e),r=[0,e];for(let s=1;s<this.rows;s++)this.get(s,e)<t&&(t=this.get(s,e),r[0]=s);return r}diag(){let e=Math.min(this.rows,this.columns),t=[];for(let r=0;r<e;r++)t.push(this.get(r,r));return t}norm(e="frobenius"){switch(e){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${e}`)}}cumulativeSum(){let e=0;for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r),this.set(t,r,e);return this}dot(e){at.isMatrix(e)&&(e=e.to1DArray());let t=this.to1DArray();if(t.length!==e.length)throw new RangeError("vectors do not have the same size");let r=0;for(let s=0;s<t.length;s++)r+=t[s]*e[s];return r}mmul(e){e=j.checkMatrix(e);let t=this.rows,r=this.columns,s=e.columns,n=new j(t,s),o=new Float64Array(r);for(let a=0;a<s;a++){for(let h=0;h<r;h++)o[h]=e.get(h,a);for(let h=0;h<t;h++){let c=0;for(let l=0;l<r;l++)c+=this.get(h,l)*o[l];n.set(h,a,c)}}return n}strassen2x2(e){e=j.checkMatrix(e);let t=new j(2,2);const r=this.get(0,0),s=e.get(0,0),n=this.get(0,1),o=e.get(0,1),a=this.get(1,0),h=e.get(1,0),c=this.get(1,1),l=e.get(1,1),u=(r+c)*(s+l),m=(a+c)*s,g=r*(o-l),y=c*(h-s),_=(r+n)*l,I=(a-r)*(s+o),w=(n-c)*(h+l),R=u+y-_+w,d=g+_,f=m+y,x=u-m+g+I;return t.set(0,0,R),t.set(0,1,d),t.set(1,0,f),t.set(1,1,x),t}strassen3x3(e){e=j.checkMatrix(e);let t=new j(3,3);const r=this.get(0,0),s=this.get(0,1),n=this.get(0,2),o=this.get(1,0),a=this.get(1,1),h=this.get(1,2),c=this.get(2,0),l=this.get(2,1),u=this.get(2,2),m=e.get(0,0),g=e.get(0,1),y=e.get(0,2),_=e.get(1,0),I=e.get(1,1),w=e.get(1,2),R=e.get(2,0),d=e.get(2,1),f=e.get(2,2),x=(r+s+n-o-a-l-u)*I,S=(r-o)*(-g+I),T=a*(-m+g+_-I-w-R+f),E=(-r+o+a)*(m-g+I),p=(o+a)*(-m+g),b=r*m,P=(-r+c+l)*(m-y+w),A=(-r+c)*(y-w),$=(c+l)*(-m+y),K=(r+s+n-a-h-c-l)*w,X=l*(-m+y+_-I-w-R+d),B=(-n+l+u)*(I+R-d),ft=(n-u)*(I-d),ct=n*R,mt=(l+u)*(-R+d),tt=(-n+a+h)*(w+R-f),_t=(n-h)*(w-f),U=(a+h)*(-R+f),nt=s*_,lt=h*d,xt=o*y,ot=c*g,Vo=u*f,qo=b+ct+nt,$o=x+E+p+b+B+ct+mt,Xo=b+P+$+K+ct+tt+U,Ho=S+T+E+b+ct+tt+_t,Yo=S+E+p+b+lt,Ko=ct+tt+_t+U+xt,Jo=b+P+A+X+B+ft+ct,Qo=B+ft+ct+mt+ot,ta=b+P+A+$+Vo;return t.set(0,0,qo),t.set(0,1,$o),t.set(0,2,Xo),t.set(1,0,Ho),t.set(1,1,Yo),t.set(1,2,Ko),t.set(2,0,Jo),t.set(2,1,Qo),t.set(2,2,ta),t}mmulStrassen(e){e=j.checkMatrix(e);let t=this.clone(),r=t.rows,s=t.columns,n=e.rows,o=e.columns;s!==n&&console.warn(`Multiplying ${r} x ${s} and ${n} x ${o} matrix: dimensions do not match.`);function a(u,m,g){let y=u.rows,_=u.columns;if(y===m&&_===g)return u;{let I=at.zeros(m,g);return I=I.setSubMatrix(u,0,0),I}}let h=Math.max(r,n),c=Math.max(s,o);t=a(t,h,c),e=a(e,h,c);function l(u,m,g,y){if(g<=512||y<=512)return u.mmul(m);g%2===1&&y%2===1?(u=a(u,g+1,y+1),m=a(m,g+1,y+1)):g%2===1?(u=a(u,g+1,y),m=a(m,g+1,y)):y%2===1&&(u=a(u,g,y+1),m=a(m,g,y+1));let _=parseInt(u.rows/2,10),I=parseInt(u.columns/2,10),w=u.subMatrix(0,_-1,0,I-1),R=m.subMatrix(0,_-1,0,I-1),d=u.subMatrix(0,_-1,I,u.columns-1),f=m.subMatrix(0,_-1,I,m.columns-1),x=u.subMatrix(_,u.rows-1,0,I-1),S=m.subMatrix(_,m.rows-1,0,I-1),T=u.subMatrix(_,u.rows-1,I,u.columns-1),E=m.subMatrix(_,m.rows-1,I,m.columns-1),p=l(at.add(w,T),at.add(R,E),_,I),b=l(at.add(x,T),R,_,I),P=l(w,at.sub(f,E),_,I),A=l(T,at.sub(S,R),_,I),$=l(at.add(w,d),E,_,I),K=l(at.sub(x,w),at.add(R,f),_,I),X=l(at.sub(d,T),at.add(S,E),_,I),B=at.add(p,A);B.sub($),B.add(X);let ft=at.add(P,$),ct=at.add(b,A),mt=at.sub(p,b);mt.add(P),mt.add(K);let tt=at.zeros(2*B.rows,2*B.columns);return tt=tt.setSubMatrix(B,0,0),tt=tt.setSubMatrix(ft,B.rows,0),tt=tt.setSubMatrix(ct,0,B.columns),tt=tt.setSubMatrix(mt,B.rows,B.columns),tt.subMatrix(0,g-1,0,y-1)}return l(t,e,h,c)}scaleRows(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(t>=r)throw new RangeError("min must be smaller than max");let s=new j(this.rows,this.columns);for(let n=0;n<this.rows;n++){const o=this.getRow(n);o.length>0&&Zs(o,{min:t,max:r,output:o}),s.setRow(n,o)}return s}scaleColumns(e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:t=0,max:r=1}=e;if(!Number.isFinite(t))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(t>=r)throw new RangeError("min must be smaller than max");let s=new j(this.rows,this.columns);for(let n=0;n<this.columns;n++){const o=this.getColumn(n);o.length&&Zs(o,{min:t,max:r,output:o}),s.setColumn(n,o)}return s}flipRows(){const e=Math.ceil(this.columns/2);for(let t=0;t<this.rows;t++)for(let r=0;r<e;r++){let s=this.get(t,r),n=this.get(t,this.columns-1-r);this.set(t,r,n),this.set(t,this.columns-1-r,s)}return this}flipColumns(){const e=Math.ceil(this.rows/2);for(let t=0;t<this.columns;t++)for(let r=0;r<e;r++){let s=this.get(r,t),n=this.get(this.rows-1-r,t);this.set(r,t,n),this.set(this.rows-1-r,t,s)}return this}kroneckerProduct(e){e=j.checkMatrix(e);let t=this.rows,r=this.columns,s=e.rows,n=e.columns,o=new j(t*s,r*n);for(let a=0;a<t;a++)for(let h=0;h<r;h++)for(let c=0;c<s;c++)for(let l=0;l<n;l++)o.set(s*a+c,n*h+l,this.get(a,h)*e.get(c,l));return o}kroneckerSum(e){if(e=j.checkMatrix(e),!this.isSquare()||!e.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let t=this.rows,r=e.rows,s=this.kroneckerProduct(j.eye(r,r)),n=j.eye(t,t).kroneckerProduct(e);return s.add(n)}transpose(){let e=new j(this.columns,this.rows);for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e.set(r,t,this.get(t,r));return e}sortRows(e=qs){for(let t=0;t<this.rows;t++)this.setRow(t,this.getRow(t).sort(e));return this}sortColumns(e=qs){for(let t=0;t<this.columns;t++)this.setColumn(t,this.getColumn(t).sort(e));return this}subMatrix(e,t,r,s){Vi(this,e,t,r,s);let n=new j(t-e+1,s-r+1);for(let o=e;o<=t;o++)for(let a=r;a<=s;a++)n.set(o-e,a-r,this.get(o,a));return n}subMatrixRow(e,t,r){if(t===void 0&&(t=0),r===void 0&&(r=this.columns-1),t>r||t<0||t>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let s=new j(e.length,r-t+1);for(let n=0;n<e.length;n++)for(let o=t;o<=r;o++){if(e[n]<0||e[n]>=this.rows)throw new RangeError(`Row index out of range: ${e[n]}`);s.set(n,o-t,this.get(e[n],o))}return s}subMatrixColumn(e,t,r){if(t===void 0&&(t=0),r===void 0&&(r=this.rows-1),t>r||t<0||t>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let s=new j(r-t+1,e.length);for(let n=0;n<e.length;n++)for(let o=t;o<=r;o++){if(e[n]<0||e[n]>=this.columns)throw new RangeError(`Column index out of range: ${e[n]}`);s.set(o-t,n,this.get(o,e[n]))}return s}setSubMatrix(e,t,r){if(e=j.checkMatrix(e),e.isEmpty())return this;let s=t+e.rows-1,n=r+e.columns-1;Vi(this,t,s,r,n);for(let o=0;o<e.rows;o++)for(let a=0;a<e.columns;a++)this.set(t+o,r+a,e.get(o,a));return this}selection(e,t){ss(this,e),ns(this,t);let r=new j(e.length,t.length);for(let s=0;s<e.length;s++){let n=e[s];for(let o=0;o<t.length;o++){let a=t[o];r.set(s,o,this.get(n,a))}}return r}trace(){let e=Math.min(this.rows,this.columns),t=0;for(let r=0;r<e;r++)t+=this.get(r,r);return t}clone(){return this.constructor.copy(this,new j(this.rows,this.columns))}static copy(e,t){for(const[r,s,n]of e.entries())t.set(r,s,n);return t}sum(e){switch(e){case"row":return Wc(this);case"column":return Zc(this);case void 0:return Vc(this);default:throw new Error(`invalid option: ${e}`)}}product(e){switch(e){case"row":return qc(this);case"column":return $c(this);case void 0:return Xc(this);default:throw new Error(`invalid option: ${e}`)}}mean(e){const t=this.sum(e);switch(e){case"row":{for(let r=0;r<this.rows;r++)t[r]/=this.columns;return t}case"column":{for(let r=0;r<this.columns;r++)t[r]/=this.rows;return t}case void 0:return t/this.size;default:throw new Error(`invalid option: ${e}`)}}variance(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");const{unbiased:r=!0,mean:s=this.mean(e)}=t;if(typeof r!="boolean")throw new TypeError("unbiased must be a boolean");switch(e){case"row":{if(!wt.isAnyArray(s))throw new TypeError("mean must be an array");return Hc(this,r,s)}case"column":{if(!wt.isAnyArray(s))throw new TypeError("mean must be an array");return Yc(this,r,s)}case void 0:{if(typeof s!="number")throw new TypeError("mean must be a number");return Kc(this,r,s)}default:throw new Error(`invalid option: ${e}`)}}standardDeviation(e,t){typeof e=="object"&&(t=e,e=void 0);const r=this.variance(e,t);if(e===void 0)return Math.sqrt(r);for(let s=0;s<r.length;s++)r[s]=Math.sqrt(r[s]);return r}center(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");const{center:r=this.mean(e)}=t;switch(e){case"row":{if(!wt.isAnyArray(r))throw new TypeError("center must be an array");return Jc(this,r),this}case"column":{if(!wt.isAnyArray(r))throw new TypeError("center must be an array");return Qc(this,r),this}case void 0:{if(typeof r!="number")throw new TypeError("center must be a number");return tl(this,r),this}default:throw new Error(`invalid option: ${e}`)}}scale(e,t={}){if(typeof e=="object"&&(t=e,e=void 0),typeof t!="object")throw new TypeError("options must be an object");let r=t.scale;switch(e){case"row":{if(r===void 0)r=el(this);else if(!wt.isAnyArray(r))throw new TypeError("scale must be an array");return rl(this,r),this}case"column":{if(r===void 0)r=il(this);else if(!wt.isAnyArray(r))throw new TypeError("scale must be an array");return sl(this,r),this}case void 0:{if(r===void 0)r=nl(this);else if(typeof r!="number")throw new TypeError("scale must be a number");return ol(this,r),this}default:throw new Error(`invalid option: ${e}`)}}toString(e){return Kn(this,e)}[Symbol.iterator](){return this.entries()}*entries(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield[e,t,this.get(e,t)]}*values(){for(let e=0;e<this.rows;e++)for(let t=0;t<this.columns;t++)yield this.get(e,t)}};rt.prototype.klass="Matrix";typeof Symbol<"u"&&(rt.prototype[Symbol.for("nodejs.util.inspect.custom")]=Gc);function qs(i,e){return i-e}function al(i){return i.every(e=>typeof e=="number")}rt.random=rt.rand;rt.randomInt=rt.randInt;rt.diagonal=rt.diag;rt.prototype.diagonal=rt.prototype.diag;rt.identity=rt.eye;rt.prototype.negate=rt.prototype.neg;rt.prototype.tensorProduct=rt.prototype.kroneckerProduct;var ir,qi,Ie;let j=(Ie=class extends rt{constructor(t,r){super();wi(this,ir);M(this,"data");if(Ie.isMatrix(t))xi(this,ir,qi).call(this,t.rows,t.columns),Ie.copy(t,this);else if(Number.isInteger(t)&&t>=0)xi(this,ir,qi).call(this,t,r);else if(wt.isAnyArray(t)){const s=t;if(t=s.length,r=t?s[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(s[n].length!==r)throw new RangeError("Inconsistent array dimensions");if(!al(s[n]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(s[n]))}this.rows=t,this.columns=r}else throw new TypeError("First argument must be a positive number or an array")}set(t,r,s){return this.data[t][r]=s,this}get(t,r){return this.data[t][r]}removeRow(t){return Tt(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,r){return r===void 0&&(r=t,t=this.rows),Tt(this,t,!0),r=Float64Array.from(ge(this,r)),this.data.splice(t,0,r),this.rows+=1,this}removeColumn(t){Pt(this,t);for(let r=0;r<this.rows;r++){const s=new Float64Array(this.columns-1);for(let n=0;n<t;n++)s[n]=this.data[r][n];for(let n=t+1;n<this.columns;n++)s[n-1]=this.data[r][n];this.data[r]=s}return this.columns-=1,this}addColumn(t,r){typeof r>"u"&&(r=t,t=this.columns),Pt(this,t,!0),r=ye(this,r);for(let s=0;s<this.rows;s++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[s][o];for(n[o++]=r[s];o<this.columns+1;o++)n[o]=this.data[s][o-1];this.data[s]=n}return this.columns+=1,this}},ir=new WeakSet,qi=function(t,r){if(this.data=[],Number.isInteger(r)&&r>=0)for(let s=0;s<t;s++)this.data.push(new Float64Array(r));else throw new TypeError("nColumns must be a positive integer");this.rows=t,this.columns=r},Ie);zc(rt,j);var ut;const ei=class ei extends rt{constructor(t){super();wi(this,ut,void 0);if(j.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");cr(this,ut,j.copy(t,new j(t.rows,t.rows)))}else if(Number.isInteger(t)&&t>=0)cr(this,ut,new j(t,t));else if(cr(this,ut,new j(t)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Rt(this,ut).size}get rows(){return Rt(this,ut).rows}get columns(){return Rt(this,ut).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return j.isMatrix(t)&&t.klassType==="SymmetricMatrix"}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}clone(){const t=new ei(this.diagonalSize);for(const[r,s,n]of this.upperRightEntries())t.set(r,s,n);return t}toMatrix(){return new j(this)}get(t,r){return Rt(this,ut).get(t,r)}set(t,r,s){return Rt(this,ut).set(t,r,s),Rt(this,ut).set(r,t,s),this}removeCross(t){return Rt(this,ut).removeRow(t),Rt(this,ut).removeColumn(t),this}addCross(t,r){r===void 0&&(r=t,t=this.diagonalSize);const s=r.slice();return s.splice(t,1),Rt(this,ut).addRow(t,s),Rt(this,ut).addColumn(t,r),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[s,n]of t.entries())n||r.push(s);r.reverse();for(const s of r)this.removeCross(s);return this}toCompact(){const{diagonalSize:t}=this,r=new Array(t*(t+1)/2);for(let s=0,n=0,o=0;o<r.length;o++)r[o]=this.get(n,s),++s>=t&&(s=++n);return r}static fromCompact(t){const r=t.length,s=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(s))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const n=new ei(s);for(let o=0,a=0,h=0;h<r;h++)n.set(o,a,t[h]),++o>=s&&(o=++a);return n}*upperRightEntries(){for(let t=0,r=0;t<this.diagonalSize;void 0){const s=this.get(t,r);yield[t,r,s],++r>=this.diagonalSize&&(r=++t)}}*upperRightValues(){for(let t=0,r=0;t<this.diagonalSize;void 0)yield this.get(t,r),++r>=this.diagonalSize&&(r=++t)}};ut=new WeakMap;let oe=ei;oe.prototype.klassType="SymmetricMatrix";class ai extends oe{static isDistanceMatrix(e){return oe.isSymmetricMatrix(e)&&e.klassSubType==="DistanceMatrix"}constructor(e){if(super(e),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(e,t,r){return e===t&&(r=0),super.set(e,t,r)}addCross(e,t){return t===void 0&&(t=e,e=this.diagonalSize),t=t.slice(),t[e]=0,super.addCross(e,t)}toSymmetricMatrix(){return new oe(this)}clone(){const e=new ai(this.diagonalSize);for(const[t,r,s]of this.upperRightEntries())t!==r&&e.set(t,r,s);return e}toCompact(){const{diagonalSize:e}=this,t=(e-1)*e/2,r=new Array(t);for(let s=1,n=0,o=0;o<r.length;o++)r[o]=this.get(n,s),++s>=e&&(s=++n+1);return r}static fromCompact(e){const t=e.length,r=(Math.sqrt(8*t+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(e)}`);const s=new this(r);for(let n=1,o=0,a=0;a<t;a++)s.set(n,o,e[a]),++n>=r&&(n=++o+1);return s}}ai.prototype.klassSubType="DistanceMatrix";class Yt extends rt{constructor(e,t,r){super(),this.matrix=e,this.rows=t,this.columns=r}}class hl extends Yt{constructor(e,t){Pt(e,t),super(e,e.rows,1),this.column=t}set(e,t,r){return this.matrix.set(e,this.column,r),this}get(e){return this.matrix.get(e,this.column)}}class cl extends Yt{constructor(e,t){ns(e,t),super(e,e.rows,t.length),this.columnIndices=t}set(e,t,r){return this.matrix.set(e,this.columnIndices[t],r),this}get(e,t){return this.matrix.get(e,this.columnIndices[t])}}class ll extends Yt{constructor(e){super(e,e.rows,e.columns)}set(e,t,r){return this.matrix.set(e,this.columns-t-1,r),this}get(e,t){return this.matrix.get(e,this.columns-t-1)}}class ul extends Yt{constructor(e){super(e,e.rows,e.columns)}set(e,t,r){return this.matrix.set(this.rows-e-1,t,r),this}get(e,t){return this.matrix.get(this.rows-e-1,t)}}class dl extends Yt{constructor(e,t){Tt(e,t),super(e,1,e.columns),this.row=t}set(e,t,r){return this.matrix.set(this.row,t,r),this}get(e,t){return this.matrix.get(this.row,t)}}class pl extends Yt{constructor(e,t){ss(e,t),super(e,t.length,e.columns),this.rowIndices=t}set(e,t,r){return this.matrix.set(this.rowIndices[e],t,r),this}get(e,t){return this.matrix.get(this.rowIndices[e],t)}}class Cr extends Yt{constructor(e,t,r){ss(e,t),ns(e,r),super(e,t.length,r.length),this.rowIndices=t,this.columnIndices=r}set(e,t,r){return this.matrix.set(this.rowIndices[e],this.columnIndices[t],r),this}get(e,t){return this.matrix.get(this.rowIndices[e],this.columnIndices[t])}}class fl extends Yt{constructor(e,t,r,s,n){Vi(e,t,r,s,n),super(e,r-t+1,n-s+1),this.startRow=t,this.startColumn=s}set(e,t,r){return this.matrix.set(this.startRow+e,this.startColumn+t,r),this}get(e,t){return this.matrix.get(this.startRow+e,this.startColumn+t)}}class ml extends Yt{constructor(e){super(e,e.columns,e.rows)}set(e,t,r){return this.matrix.set(t,e,r),this}get(e,t){return this.matrix.get(t,e)}}class Jn extends rt{constructor(e,t={}){const{rows:r=1}=t;if(e.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=e.length/r,this.data=e}set(e,t,r){let s=this._calculateIndex(e,t);return this.data[s]=r,this}get(e,t){let r=this._calculateIndex(e,t);return this.data[r]}_calculateIndex(e,t){return e*this.columns+t}}let Et=class extends rt{constructor(i){super(),this.data=i,this.rows=i.length,this.columns=i[0].length}set(i,e,t){return this.data[i][e]=t,this}get(i,e){return this.data[i][e]}};function gl(i,e){if(wt.isAnyArray(i))return i[0]&&wt.isAnyArray(i[0])?new Et(i):new Jn(i,e);throw new Error("the argument is not an array")}class hi{constructor(e){e=Et.checkMatrix(e);let t=e.clone(),r=t.rows,s=t.columns,n=new Float64Array(r),o=1,a,h,c,l,u,m,g,y,_;for(a=0;a<r;a++)n[a]=a;for(y=new Float64Array(r),h=0;h<s;h++){for(a=0;a<r;a++)y[a]=t.get(a,h);for(a=0;a<r;a++){for(_=Math.min(a,h),u=0,c=0;c<_;c++)u+=t.get(a,c)*y[c];y[a]-=u,t.set(a,h,y[a])}for(l=h,a=h+1;a<r;a++)Math.abs(y[a])>Math.abs(y[l])&&(l=a);if(l!==h){for(c=0;c<s;c++)m=t.get(l,c),t.set(l,c,t.get(h,c)),t.set(h,c,m);g=n[l],n[l]=n[h],n[h]=g,o=-o}if(h<r&&t.get(h,h)!==0)for(a=h+1;a<r;a++)t.set(a,h,t.get(a,h)/t.get(h,h))}this.LU=t,this.pivotVector=n,this.pivotSign=o}isSingular(){let e=this.LU,t=e.columns;for(let r=0;r<t;r++)if(e.get(r,r)===0)return!0;return!1}solve(e){e=j.checkMatrix(e);let t=this.LU;if(t.rows!==e.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let r=e.columns,s=e.subMatrixRow(this.pivotVector,0,r-1),n=t.columns,o,a,h;for(h=0;h<n;h++)for(o=h+1;o<n;o++)for(a=0;a<r;a++)s.set(o,a,s.get(o,a)-s.get(h,a)*t.get(o,h));for(h=n-1;h>=0;h--){for(a=0;a<r;a++)s.set(h,a,s.get(h,a)/t.get(h,h));for(o=0;o<h;o++)for(a=0;a<r;a++)s.set(o,a,s.get(o,a)-s.get(h,a)*t.get(o,h))}return s}get determinant(){let e=this.LU;if(!e.isSquare())throw new Error("Matrix must be square");let t=this.pivotSign,r=e.columns;for(let s=0;s<r;s++)t*=e.get(s,s);return t}get lowerTriangularMatrix(){let e=this.LU,t=e.rows,r=e.columns,s=new j(t,r);for(let n=0;n<t;n++)for(let o=0;o<r;o++)n>o?s.set(n,o,e.get(n,o)):n===o?s.set(n,o,1):s.set(n,o,0);return s}get upperTriangularMatrix(){let e=this.LU,t=e.rows,r=e.columns,s=new j(t,r);for(let n=0;n<t;n++)for(let o=0;o<r;o++)n<=o?s.set(n,o,e.get(n,o)):s.set(n,o,0);return s}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Xt(i,e){let t=0;return Math.abs(i)>Math.abs(e)?(t=e/i,Math.abs(i)*Math.sqrt(1+t*t)):e!==0?(t=i/e,Math.abs(e)*Math.sqrt(1+t*t)):0}class os{constructor(e){e=Et.checkMatrix(e);let t=e.clone(),r=e.rows,s=e.columns,n=new Float64Array(s),o,a,h,c;for(h=0;h<s;h++){let l=0;for(o=h;o<r;o++)l=Xt(l,t.get(o,h));if(l!==0){for(t.get(h,h)<0&&(l=-l),o=h;o<r;o++)t.set(o,h,t.get(o,h)/l);for(t.set(h,h,t.get(h,h)+1),a=h+1;a<s;a++){for(c=0,o=h;o<r;o++)c+=t.get(o,h)*t.get(o,a);for(c=-c/t.get(h,h),o=h;o<r;o++)t.set(o,a,t.get(o,a)+c*t.get(o,h))}}n[h]=-l}this.QR=t,this.Rdiag=n}solve(e){e=j.checkMatrix(e);let t=this.QR,r=t.rows;if(e.rows!==r)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let s=e.columns,n=e.clone(),o=t.columns,a,h,c,l;for(c=0;c<o;c++)for(h=0;h<s;h++){for(l=0,a=c;a<r;a++)l+=t.get(a,c)*n.get(a,h);for(l=-l/t.get(c,c),a=c;a<r;a++)n.set(a,h,n.get(a,h)+l*t.get(a,c))}for(c=o-1;c>=0;c--){for(h=0;h<s;h++)n.set(c,h,n.get(c,h)/this.Rdiag[c]);for(a=0;a<c;a++)for(h=0;h<s;h++)n.set(a,h,n.get(a,h)-n.get(c,h)*t.get(a,c))}return n.subMatrix(0,o-1,0,s-1)}isFullRank(){let e=this.QR.columns;for(let t=0;t<e;t++)if(this.Rdiag[t]===0)return!1;return!0}get upperTriangularMatrix(){let e=this.QR,t=e.columns,r=new j(t,t),s,n;for(s=0;s<t;s++)for(n=0;n<t;n++)s<n?r.set(s,n,e.get(s,n)):s===n?r.set(s,n,this.Rdiag[s]):r.set(s,n,0);return r}get orthogonalMatrix(){let e=this.QR,t=e.rows,r=e.columns,s=new j(t,r),n,o,a,h;for(a=r-1;a>=0;a--){for(n=0;n<t;n++)s.set(n,a,0);for(s.set(a,a,1),o=a;o<r;o++)if(e.get(a,a)!==0){for(h=0,n=a;n<t;n++)h+=e.get(n,a)*s.get(n,o);for(h=-h/e.get(a,a),n=a;n<t;n++)s.set(n,o,s.get(n,o)+h*e.get(n,a))}}return s}}let Re=class{constructor(i,e={}){if(i=Et.checkMatrix(i),i.isEmpty())throw new Error("Matrix must be non-empty");let t=i.rows,r=i.columns;const{computeLeftSingularVectors:s=!0,computeRightSingularVectors:n=!0,autoTranspose:o=!1}=e;let a=!!s,h=!!n,c=!1,l;if(t<r)if(!o)l=i.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{l=i.transpose(),t=l.rows,r=l.columns,c=!0;let p=a;a=h,h=p}else l=i.clone();let u=Math.min(t,r),m=Math.min(t+1,r),g=new Float64Array(m),y=new j(t,u),_=new j(r,r),I=new Float64Array(r),w=new Float64Array(t),R=new Float64Array(m);for(let p=0;p<m;p++)R[p]=p;let d=Math.min(t-1,r),f=Math.max(0,Math.min(r-2,t)),x=Math.max(d,f);for(let p=0;p<x;p++){if(p<d){g[p]=0;for(let b=p;b<t;b++)g[p]=Xt(g[p],l.get(b,p));if(g[p]!==0){l.get(p,p)<0&&(g[p]=-g[p]);for(let b=p;b<t;b++)l.set(b,p,l.get(b,p)/g[p]);l.set(p,p,l.get(p,p)+1)}g[p]=-g[p]}for(let b=p+1;b<r;b++){if(p<d&&g[p]!==0){let P=0;for(let A=p;A<t;A++)P+=l.get(A,p)*l.get(A,b);P=-P/l.get(p,p);for(let A=p;A<t;A++)l.set(A,b,l.get(A,b)+P*l.get(A,p))}I[b]=l.get(p,b)}if(a&&p<d)for(let b=p;b<t;b++)y.set(b,p,l.get(b,p));if(p<f){I[p]=0;for(let b=p+1;b<r;b++)I[p]=Xt(I[p],I[b]);if(I[p]!==0){I[p+1]<0&&(I[p]=0-I[p]);for(let b=p+1;b<r;b++)I[b]/=I[p];I[p+1]+=1}if(I[p]=-I[p],p+1<t&&I[p]!==0){for(let b=p+1;b<t;b++)w[b]=0;for(let b=p+1;b<t;b++)for(let P=p+1;P<r;P++)w[b]+=I[P]*l.get(b,P);for(let b=p+1;b<r;b++){let P=-I[b]/I[p+1];for(let A=p+1;A<t;A++)l.set(A,b,l.get(A,b)+P*w[A])}}if(h)for(let b=p+1;b<r;b++)_.set(b,p,I[b])}}let S=Math.min(r,t+1);if(d<r&&(g[d]=l.get(d,d)),t<S&&(g[S-1]=0),f+1<S&&(I[f]=l.get(f,S-1)),I[S-1]=0,a){for(let p=d;p<u;p++){for(let b=0;b<t;b++)y.set(b,p,0);y.set(p,p,1)}for(let p=d-1;p>=0;p--)if(g[p]!==0){for(let b=p+1;b<u;b++){let P=0;for(let A=p;A<t;A++)P+=y.get(A,p)*y.get(A,b);P=-P/y.get(p,p);for(let A=p;A<t;A++)y.set(A,b,y.get(A,b)+P*y.get(A,p))}for(let b=p;b<t;b++)y.set(b,p,-y.get(b,p));y.set(p,p,1+y.get(p,p));for(let b=0;b<p-1;b++)y.set(b,p,0)}else{for(let b=0;b<t;b++)y.set(b,p,0);y.set(p,p,1)}}if(h)for(let p=r-1;p>=0;p--){if(p<f&&I[p]!==0)for(let b=p+1;b<r;b++){let P=0;for(let A=p+1;A<r;A++)P+=_.get(A,p)*_.get(A,b);P=-P/_.get(p+1,p);for(let A=p+1;A<r;A++)_.set(A,b,_.get(A,b)+P*_.get(A,p))}for(let b=0;b<r;b++)_.set(b,p,0);_.set(p,p,1)}let T=S-1,E=Number.EPSILON;for(;S>0;){let p,b;for(p=S-2;p>=-1&&p!==-1;p--){const P=Number.MIN_VALUE+E*Math.abs(g[p]+Math.abs(g[p+1]));if(Math.abs(I[p])<=P||Number.isNaN(I[p])){I[p]=0;break}}if(p===S-2)b=4;else{let P;for(P=S-1;P>=p&&P!==p;P--){let A=(P!==S?Math.abs(I[P]):0)+(P!==p+1?Math.abs(I[P-1]):0);if(Math.abs(g[P])<=E*A){g[P]=0;break}}P===p?b=3:P===S-1?b=1:(b=2,p=P)}switch(p++,b){case 1:{let P=I[S-2];I[S-2]=0;for(let A=S-2;A>=p;A--){let $=Xt(g[A],P),K=g[A]/$,X=P/$;if(g[A]=$,A!==p&&(P=-X*I[A-1],I[A-1]=K*I[A-1]),h)for(let B=0;B<r;B++)$=K*_.get(B,A)+X*_.get(B,S-1),_.set(B,S-1,-X*_.get(B,A)+K*_.get(B,S-1)),_.set(B,A,$)}break}case 2:{let P=I[p-1];I[p-1]=0;for(let A=p;A<S;A++){let $=Xt(g[A],P),K=g[A]/$,X=P/$;if(g[A]=$,P=-X*I[A],I[A]=K*I[A],a)for(let B=0;B<t;B++)$=K*y.get(B,A)+X*y.get(B,p-1),y.set(B,p-1,-X*y.get(B,A)+K*y.get(B,p-1)),y.set(B,A,$)}break}case 3:{const P=Math.max(Math.abs(g[S-1]),Math.abs(g[S-2]),Math.abs(I[S-2]),Math.abs(g[p]),Math.abs(I[p])),A=g[S-1]/P,$=g[S-2]/P,K=I[S-2]/P,X=g[p]/P,B=I[p]/P,ft=(($+A)*($-A)+K*K)/2,ct=A*K*(A*K);let mt=0;(ft!==0||ct!==0)&&(ft<0?mt=0-Math.sqrt(ft*ft+ct):mt=Math.sqrt(ft*ft+ct),mt=ct/(ft+mt));let tt=(X+A)*(X-A)+mt,_t=X*B;for(let U=p;U<S-1;U++){let nt=Xt(tt,_t);nt===0&&(nt=Number.MIN_VALUE);let lt=tt/nt,xt=_t/nt;if(U!==p&&(I[U-1]=nt),tt=lt*g[U]+xt*I[U],I[U]=lt*I[U]-xt*g[U],_t=xt*g[U+1],g[U+1]=lt*g[U+1],h)for(let ot=0;ot<r;ot++)nt=lt*_.get(ot,U)+xt*_.get(ot,U+1),_.set(ot,U+1,-xt*_.get(ot,U)+lt*_.get(ot,U+1)),_.set(ot,U,nt);if(nt=Xt(tt,_t),nt===0&&(nt=Number.MIN_VALUE),lt=tt/nt,xt=_t/nt,g[U]=nt,tt=lt*I[U]+xt*g[U+1],g[U+1]=-xt*I[U]+lt*g[U+1],_t=xt*I[U+1],I[U+1]=lt*I[U+1],a&&U<t-1)for(let ot=0;ot<t;ot++)nt=lt*y.get(ot,U)+xt*y.get(ot,U+1),y.set(ot,U+1,-xt*y.get(ot,U)+lt*y.get(ot,U+1)),y.set(ot,U,nt)}I[S-2]=tt;break}case 4:{if(g[p]<=0&&(g[p]=g[p]<0?-g[p]:0,h))for(let P=0;P<=T;P++)_.set(P,p,-_.get(P,p));for(;p<T&&!(g[p]>=g[p+1]);){let P=g[p];if(g[p]=g[p+1],g[p+1]=P,h&&p<r-1)for(let A=0;A<r;A++)P=_.get(A,p+1),_.set(A,p+1,_.get(A,p)),_.set(A,p,P);if(a&&p<t-1)for(let A=0;A<t;A++)P=y.get(A,p+1),y.set(A,p+1,y.get(A,p)),y.set(A,p,P);p++}S--;break}}}if(c){let p=_;_=y,y=p}this.m=t,this.n=r,this.s=g,this.U=y,this.V=_}solve(i){let e=i,t=this.threshold,r=this.s.length,s=j.zeros(r,r);for(let u=0;u<r;u++)Math.abs(this.s[u])<=t?s.set(u,u,0):s.set(u,u,1/this.s[u]);let n=this.U,o=this.rightSingularVectors,a=o.mmul(s),h=o.rows,c=n.rows,l=j.zeros(h,c);for(let u=0;u<h;u++)for(let m=0;m<c;m++){let g=0;for(let y=0;y<r;y++)g+=a.get(u,y)*n.get(m,y);l.set(u,m,g)}return l.mmul(e)}solveForDiagonal(i){return this.solve(j.diag(i))}inverse(){let i=this.V,e=this.threshold,t=i.rows,r=i.columns,s=new j(t,this.s.length);for(let c=0;c<t;c++)for(let l=0;l<r;l++)Math.abs(this.s[l])>e&&s.set(c,l,i.get(c,l)/this.s[l]);let n=this.U,o=n.rows,a=n.columns,h=new j(t,o);for(let c=0;c<t;c++)for(let l=0;l<o;l++){let u=0;for(let m=0;m<a;m++)u+=s.get(c,m)*n.get(l,m);h.set(c,l,u)}return h}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let i=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,t=this.s;for(let r=0,s=t.length;r<s;r++)t[r]>i&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return j.diag(this.s)}};function yl(i,e=!1){return i=Et.checkMatrix(i),e?new Re(i).inverse():Qn(i,j.eye(i.rows))}function Qn(i,e,t=!1){return i=Et.checkMatrix(i),e=Et.checkMatrix(e),t?new Re(i).solve(e):i.isSquare()?new hi(i).solve(e):new os(i).solve(e)}function kr(i){if(i=j.checkMatrix(i),i.isSquare()){if(i.columns===0)return 1;let e,t,r,s;if(i.columns===2)return e=i.get(0,0),t=i.get(0,1),r=i.get(1,0),s=i.get(1,1),e*s-t*r;if(i.columns===3){let n,o,a;return n=new Cr(i,[1,2],[1,2]),o=new Cr(i,[1,2],[0,2]),a=new Cr(i,[1,2],[0,1]),e=i.get(0,0),t=i.get(0,1),r=i.get(0,2),e*kr(n)-t*kr(o)+r*kr(a)}else return new hi(i).determinant}else throw Error("determinant can only be calculated for a square matrix")}function vl(i,e){let t=[];for(let r=0;r<i;r++)r!==e&&t.push(r);return t}function wl(i,e,t,r=1e-9,s=1e-9){if(i>s)return new Array(e.rows+1).fill(0);{let n=e.addRow(t,[0]);for(let o=0;o<n.rows;o++)Math.abs(n.get(o,0))<r&&n.set(o,0,0);return n.to1DArray()}}function xl(i,e={}){const{thresholdValue:t=1e-9,thresholdError:r=1e-9}=e;i=j.checkMatrix(i);let s=i.rows,n=new j(s,s);for(let o=0;o<s;o++){let a=j.columnVector(i.getRow(o)),h=i.subMatrixRow(vl(s,o)).transpose(),c=new Re(h).solve(a),l=j.sub(a,h.mmul(c)).abs().max();n.setRow(o,wl(l,c,o,t,r))}return n}function bl(i,e=Number.EPSILON){if(i=j.checkMatrix(i),i.isEmpty())return i.transpose();let t=new Re(i,{autoTranspose:!0}),r=t.leftSingularVectors,s=t.rightSingularVectors,n=t.diagonal;for(let o=0;o<n.length;o++)Math.abs(n[o])>e?n[o]=1/n[o]:n[o]=0;return s.mmul(j.diag(n).mmul(r.transpose()))}function Ml(i,e=i,t={}){i=new j(i);let r=!1;if(typeof e=="object"&&!j.isMatrix(e)&&!wt.isAnyArray(e)?(t=e,e=i,r=!0):e=new j(e),i.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:s=!0}=t;s&&(i=i.center("column"),r||(e=e.center("column")));const n=i.transpose().mmul(e);for(let o=0;o<n.rows;o++)for(let a=0;a<n.columns;a++)n.set(o,a,n.get(o,a)*(1/(i.rows-1)));return n}function El(i,e=i,t={}){i=new j(i);let r=!1;if(typeof e=="object"&&!j.isMatrix(e)&&!wt.isAnyArray(e)?(t=e,e=i,r=!0):e=new j(e),i.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:s=!0,scale:n=!0}=t;s&&(i.center("column"),r||e.center("column")),n&&(i.scale("column"),r||e.scale("column"));const o=i.standardDeviation("column",{unbiased:!0}),a=r?o:e.standardDeviation("column",{unbiased:!0}),h=i.transpose().mmul(e);for(let c=0;c<h.rows;c++)for(let l=0;l<h.columns;l++)h.set(c,l,h.get(c,l)*(1/(o[c]*a[l]))*(1/(i.rows-1)));return h}class to{constructor(e,t={}){const{assumeSymmetric:r=!1}=t;if(e=Et.checkMatrix(e),!e.isSquare())throw new Error("Matrix is not a square matrix");if(e.isEmpty())throw new Error("Matrix must be non-empty");let s=e.columns,n=new j(s,s),o=new Float64Array(s),a=new Float64Array(s),h=e,c,l,u=!1;if(r?u=!0:u=e.isSymmetric(),u){for(c=0;c<s;c++)for(l=0;l<s;l++)n.set(c,l,h.get(c,l));_l(s,a,o,n),Tl(s,a,o,n)}else{let m=new j(s,s),g=new Float64Array(s);for(l=0;l<s;l++)for(c=0;c<s;c++)m.set(c,l,h.get(c,l));Pl(s,m,g,n),Il(s,a,o,n,m)}this.n=s,this.e=a,this.d=o,this.V=n}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let e=this.n,t=this.e,r=this.d,s=new j(e,e),n,o;for(n=0;n<e;n++){for(o=0;o<e;o++)s.set(n,o,0);s.set(n,n,r[n]),t[n]>0?s.set(n,n+1,t[n]):t[n]<0&&s.set(n,n-1,t[n])}return s}}function _l(i,e,t,r){let s,n,o,a,h,c,l,u;for(h=0;h<i;h++)t[h]=r.get(i-1,h);for(a=i-1;a>0;a--){for(u=0,o=0,c=0;c<a;c++)u=u+Math.abs(t[c]);if(u===0)for(e[a]=t[a-1],h=0;h<a;h++)t[h]=r.get(a-1,h),r.set(a,h,0),r.set(h,a,0);else{for(c=0;c<a;c++)t[c]/=u,o+=t[c]*t[c];for(s=t[a-1],n=Math.sqrt(o),s>0&&(n=-n),e[a]=u*n,o=o-s*n,t[a-1]=s-n,h=0;h<a;h++)e[h]=0;for(h=0;h<a;h++){for(s=t[h],r.set(h,a,s),n=e[h]+r.get(h,h)*s,c=h+1;c<=a-1;c++)n+=r.get(c,h)*t[c],e[c]+=r.get(c,h)*s;e[h]=n}for(s=0,h=0;h<a;h++)e[h]/=o,s+=e[h]*t[h];for(l=s/(o+o),h=0;h<a;h++)e[h]-=l*t[h];for(h=0;h<a;h++){for(s=t[h],n=e[h],c=h;c<=a-1;c++)r.set(c,h,r.get(c,h)-(s*e[c]+n*t[c]));t[h]=r.get(a-1,h),r.set(a,h,0)}}t[a]=o}for(a=0;a<i-1;a++){if(r.set(i-1,a,r.get(a,a)),r.set(a,a,1),o=t[a+1],o!==0){for(c=0;c<=a;c++)t[c]=r.get(c,a+1)/o;for(h=0;h<=a;h++){for(n=0,c=0;c<=a;c++)n+=r.get(c,a+1)*r.get(c,h);for(c=0;c<=a;c++)r.set(c,h,r.get(c,h)-n*t[c])}}for(c=0;c<=a;c++)r.set(c,a+1,0)}for(h=0;h<i;h++)t[h]=r.get(i-1,h),r.set(i-1,h,0);r.set(i-1,i-1,1),e[0]=0}function Tl(i,e,t,r){let s,n,o,a,h,c,l,u,m,g,y,_,I,w,R,d;for(o=1;o<i;o++)e[o-1]=e[o];e[i-1]=0;let f=0,x=0,S=Number.EPSILON;for(c=0;c<i;c++){for(x=Math.max(x,Math.abs(t[c])+Math.abs(e[c])),l=c;l<i&&!(Math.abs(e[l])<=S*x);)l++;if(l>c)do{for(s=t[c],u=(t[c+1]-s)/(2*e[c]),m=Xt(u,1),u<0&&(m=-m),t[c]=e[c]/(u+m),t[c+1]=e[c]*(u+m),g=t[c+1],n=s-t[c],o=c+2;o<i;o++)t[o]-=n;for(f=f+n,u=t[l],y=1,_=y,I=y,w=e[c+1],R=0,d=0,o=l-1;o>=c;o--)for(I=_,_=y,d=R,s=y*e[o],n=y*u,m=Xt(u,e[o]),e[o+1]=R*m,R=e[o]/m,y=u/m,u=y*t[o]-R*s,t[o+1]=n+R*(y*s+R*t[o]),h=0;h<i;h++)n=r.get(h,o+1),r.set(h,o+1,R*r.get(h,o)+y*n),r.set(h,o,y*r.get(h,o)-R*n);u=-R*d*I*w*e[c]/g,e[c]=R*u,t[c]=y*u}while(Math.abs(e[c])>S*x);t[c]=t[c]+f,e[c]=0}for(o=0;o<i-1;o++){for(h=o,u=t[o],a=o+1;a<i;a++)t[a]<u&&(h=a,u=t[a]);if(h!==o)for(t[h]=t[o],t[o]=u,a=0;a<i;a++)u=r.get(a,o),r.set(a,o,r.get(a,h)),r.set(a,h,u)}}function Pl(i,e,t,r){let s=0,n=i-1,o,a,h,c,l,u,m;for(u=s+1;u<=n-1;u++){for(m=0,c=u;c<=n;c++)m=m+Math.abs(e.get(c,u-1));if(m!==0){for(h=0,c=n;c>=u;c--)t[c]=e.get(c,u-1)/m,h+=t[c]*t[c];for(a=Math.sqrt(h),t[u]>0&&(a=-a),h=h-t[u]*a,t[u]=t[u]-a,l=u;l<i;l++){for(o=0,c=n;c>=u;c--)o+=t[c]*e.get(c,l);for(o=o/h,c=u;c<=n;c++)e.set(c,l,e.get(c,l)-o*t[c])}for(c=0;c<=n;c++){for(o=0,l=n;l>=u;l--)o+=t[l]*e.get(c,l);for(o=o/h,l=u;l<=n;l++)e.set(c,l,e.get(c,l)-o*t[l])}t[u]=m*t[u],e.set(u,u-1,m*a)}}for(c=0;c<i;c++)for(l=0;l<i;l++)r.set(c,l,c===l?1:0);for(u=n-1;u>=s+1;u--)if(e.get(u,u-1)!==0){for(c=u+1;c<=n;c++)t[c]=e.get(c,u-1);for(l=u;l<=n;l++){for(a=0,c=u;c<=n;c++)a+=t[c]*r.get(c,l);for(a=a/t[u]/e.get(u,u-1),c=u;c<=n;c++)r.set(c,l,r.get(c,l)+a*t[c])}}}function Il(i,e,t,r,s){let n=i-1,o=0,a=i-1,h=Number.EPSILON,c=0,l=0,u=0,m=0,g=0,y=0,_=0,I=0,w,R,d,f,x,S,T,E,p,b,P,A,$,K,X;for(w=0;w<i;w++)for((w<o||w>a)&&(t[w]=s.get(w,w),e[w]=0),R=Math.max(w-1,0);R<i;R++)l=l+Math.abs(s.get(w,R));for(;n>=o;){for(f=n;f>o&&(y=Math.abs(s.get(f-1,f-1))+Math.abs(s.get(f,f)),y===0&&(y=l),!(Math.abs(s.get(f,f-1))<h*y));)f--;if(f===n)s.set(n,n,s.get(n,n)+c),t[n]=s.get(n,n),e[n]=0,n--,I=0;else if(f===n-1){if(T=s.get(n,n-1)*s.get(n-1,n),u=(s.get(n-1,n-1)-s.get(n,n))/2,m=u*u+T,_=Math.sqrt(Math.abs(m)),s.set(n,n,s.get(n,n)+c),s.set(n-1,n-1,s.get(n-1,n-1)+c),E=s.get(n,n),m>=0){for(_=u>=0?u+_:u-_,t[n-1]=E+_,t[n]=t[n-1],_!==0&&(t[n]=E-T/_),e[n-1]=0,e[n]=0,E=s.get(n,n-1),y=Math.abs(E)+Math.abs(_),u=E/y,m=_/y,g=Math.sqrt(u*u+m*m),u=u/g,m=m/g,R=n-1;R<i;R++)_=s.get(n-1,R),s.set(n-1,R,m*_+u*s.get(n,R)),s.set(n,R,m*s.get(n,R)-u*_);for(w=0;w<=n;w++)_=s.get(w,n-1),s.set(w,n-1,m*_+u*s.get(w,n)),s.set(w,n,m*s.get(w,n)-u*_);for(w=o;w<=a;w++)_=r.get(w,n-1),r.set(w,n-1,m*_+u*r.get(w,n)),r.set(w,n,m*r.get(w,n)-u*_)}else t[n-1]=E+u,t[n]=E+u,e[n-1]=_,e[n]=-_;n=n-2,I=0}else{if(E=s.get(n,n),p=0,T=0,f<n&&(p=s.get(n-1,n-1),T=s.get(n,n-1)*s.get(n-1,n)),I===10){for(c+=E,w=o;w<=n;w++)s.set(w,w,s.get(w,w)-E);y=Math.abs(s.get(n,n-1))+Math.abs(s.get(n-1,n-2)),E=p=.75*y,T=-.4375*y*y}if(I===30&&(y=(p-E)/2,y=y*y+T,y>0)){for(y=Math.sqrt(y),p<E&&(y=-y),y=E-T/((p-E)/2+y),w=o;w<=n;w++)s.set(w,w,s.get(w,w)-y);c+=y,E=p=T=.964}for(I=I+1,x=n-2;x>=f&&(_=s.get(x,x),g=E-_,y=p-_,u=(g*y-T)/s.get(x+1,x)+s.get(x,x+1),m=s.get(x+1,x+1)-_-g-y,g=s.get(x+2,x+1),y=Math.abs(u)+Math.abs(m)+Math.abs(g),u=u/y,m=m/y,g=g/y,!(x===f||Math.abs(s.get(x,x-1))*(Math.abs(m)+Math.abs(g))<h*(Math.abs(u)*(Math.abs(s.get(x-1,x-1))+Math.abs(_)+Math.abs(s.get(x+1,x+1))))));)x--;for(w=x+2;w<=n;w++)s.set(w,w-2,0),w>x+2&&s.set(w,w-3,0);for(d=x;d<=n-1&&(K=d!==n-1,d!==x&&(u=s.get(d,d-1),m=s.get(d+1,d-1),g=K?s.get(d+2,d-1):0,E=Math.abs(u)+Math.abs(m)+Math.abs(g),E!==0&&(u=u/E,m=m/E,g=g/E)),E!==0);d++)if(y=Math.sqrt(u*u+m*m+g*g),u<0&&(y=-y),y!==0){for(d!==x?s.set(d,d-1,-y*E):f!==x&&s.set(d,d-1,-s.get(d,d-1)),u=u+y,E=u/y,p=m/y,_=g/y,m=m/u,g=g/u,R=d;R<i;R++)u=s.get(d,R)+m*s.get(d+1,R),K&&(u=u+g*s.get(d+2,R),s.set(d+2,R,s.get(d+2,R)-u*_)),s.set(d,R,s.get(d,R)-u*E),s.set(d+1,R,s.get(d+1,R)-u*p);for(w=0;w<=Math.min(n,d+3);w++)u=E*s.get(w,d)+p*s.get(w,d+1),K&&(u=u+_*s.get(w,d+2),s.set(w,d+2,s.get(w,d+2)-u*g)),s.set(w,d,s.get(w,d)-u),s.set(w,d+1,s.get(w,d+1)-u*m);for(w=o;w<=a;w++)u=E*r.get(w,d)+p*r.get(w,d+1),K&&(u=u+_*r.get(w,d+2),r.set(w,d+2,r.get(w,d+2)-u*g)),r.set(w,d,r.get(w,d)-u),r.set(w,d+1,r.get(w,d+1)-u*m)}}}if(l!==0){for(n=i-1;n>=0;n--)if(u=t[n],m=e[n],m===0)for(f=n,s.set(n,n,1),w=n-1;w>=0;w--){for(T=s.get(w,w)-u,g=0,R=f;R<=n;R++)g=g+s.get(w,R)*s.get(R,n);if(e[w]<0)_=T,y=g;else if(f=w,e[w]===0?s.set(w,n,T!==0?-g/T:-g/(h*l)):(E=s.get(w,w+1),p=s.get(w+1,w),m=(t[w]-u)*(t[w]-u)+e[w]*e[w],S=(E*y-_*g)/m,s.set(w,n,S),s.set(w+1,n,Math.abs(E)>Math.abs(_)?(-g-T*S)/E:(-y-p*S)/_)),S=Math.abs(s.get(w,n)),h*S*S>1)for(R=w;R<=n;R++)s.set(R,n,s.get(R,n)/S)}else if(m<0)for(f=n-1,Math.abs(s.get(n,n-1))>Math.abs(s.get(n-1,n))?(s.set(n-1,n-1,m/s.get(n,n-1)),s.set(n-1,n,-(s.get(n,n)-u)/s.get(n,n-1))):(X=Mr(0,-s.get(n-1,n),s.get(n-1,n-1)-u,m),s.set(n-1,n-1,X[0]),s.set(n-1,n,X[1])),s.set(n,n-1,0),s.set(n,n,1),w=n-2;w>=0;w--){for(b=0,P=0,R=f;R<=n;R++)b=b+s.get(w,R)*s.get(R,n-1),P=P+s.get(w,R)*s.get(R,n);if(T=s.get(w,w)-u,e[w]<0)_=T,g=b,y=P;else if(f=w,e[w]===0?(X=Mr(-b,-P,T,m),s.set(w,n-1,X[0]),s.set(w,n,X[1])):(E=s.get(w,w+1),p=s.get(w+1,w),A=(t[w]-u)*(t[w]-u)+e[w]*e[w]-m*m,$=(t[w]-u)*2*m,A===0&&$===0&&(A=h*l*(Math.abs(T)+Math.abs(m)+Math.abs(E)+Math.abs(p)+Math.abs(_))),X=Mr(E*g-_*b+m*P,E*y-_*P-m*b,A,$),s.set(w,n-1,X[0]),s.set(w,n,X[1]),Math.abs(E)>Math.abs(_)+Math.abs(m)?(s.set(w+1,n-1,(-b-T*s.get(w,n-1)+m*s.get(w,n))/E),s.set(w+1,n,(-P-T*s.get(w,n)-m*s.get(w,n-1))/E)):(X=Mr(-g-p*s.get(w,n-1),-y-p*s.get(w,n),_,m),s.set(w+1,n-1,X[0]),s.set(w+1,n,X[1]))),S=Math.max(Math.abs(s.get(w,n-1)),Math.abs(s.get(w,n))),h*S*S>1)for(R=w;R<=n;R++)s.set(R,n-1,s.get(R,n-1)/S),s.set(R,n,s.get(R,n)/S)}for(w=0;w<i;w++)if(w<o||w>a)for(R=w;R<i;R++)r.set(w,R,s.get(w,R));for(R=i-1;R>=o;R--)for(w=o;w<=a;w++){for(_=0,d=o;d<=Math.min(R,a);d++)_=_+r.get(w,d)*s.get(d,R);r.set(w,R,_)}}}function Mr(i,e,t,r){let s,n;return Math.abs(t)>Math.abs(r)?(s=r/t,n=t+s*r,[(i+s*e)/n,(e-s*i)/n]):(s=t/r,n=r+s*t,[(s*i+e)/n,(s*e-i)/n])}class eo{constructor(e){if(e=Et.checkMatrix(e),!e.isSymmetric())throw new Error("Matrix is not symmetric");let t=e,r=t.rows,s=new j(r,r),n=!0,o,a,h;for(a=0;a<r;a++){let c=0;for(h=0;h<a;h++){let l=0;for(o=0;o<h;o++)l+=s.get(h,o)*s.get(a,o);l=(t.get(a,h)-l)/s.get(h,h),s.set(a,h,l),c=c+l*l}for(c=t.get(a,a)-c,n&=c>0,s.set(a,a,Math.sqrt(Math.max(c,0))),h=a+1;h<r;h++)s.set(a,h,0)}this.L=s,this.positiveDefinite=!!n}isPositiveDefinite(){return this.positiveDefinite}solve(e){e=Et.checkMatrix(e);let t=this.L,r=t.rows;if(e.rows!==r)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let s=e.columns,n=e.clone(),o,a,h;for(h=0;h<r;h++)for(a=0;a<s;a++){for(o=0;o<h;o++)n.set(h,a,n.get(h,a)-n.get(o,a)*t.get(h,o));n.set(h,a,n.get(h,a)/t.get(h,h))}for(h=r-1;h>=0;h--)for(a=0;a<s;a++){for(o=h+1;o<r;o++)n.set(h,a,n.get(h,a)-n.get(o,a)*t.get(o,h));n.set(h,a,n.get(h,a)/t.get(h,h))}return n}get lowerTriangularMatrix(){return this.L}}class ro{constructor(e,t={}){e=Et.checkMatrix(e);let{Y:r}=t;const{scaleScores:s=!1,maxIterations:n=1e3,terminationCriteria:o=1e-10}=t;let a;if(r){if(wt.isAnyArray(r)&&typeof r[0]=="number"?r=j.columnVector(r):r=Et.checkMatrix(r),r.rows!==e.rows)throw new Error("Y should have the same number of rows as X");a=r.getColumnVector(0)}else a=e.getColumnVector(0);let h=1,c,l,u,m;for(let g=0;g<n&&h>o;g++)u=e.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),c=e.mmul(u).div(u.transpose().mmul(u).get(0,0)),g>0&&(h=c.clone().sub(m).pow(2).sum()),m=c.clone(),r?(l=r.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0)),l=l.div(l.norm()),a=r.mmul(l).div(l.transpose().mmul(l).get(0,0))):a=c;if(r){let g=e.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0));g=g.div(g.norm());let y=e.clone().sub(c.clone().mmul(g.transpose())),_=a.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0)),I=r.clone().sub(c.clone().mulS(_.get(0,0)).mmul(l.transpose()));this.t=c,this.p=g.transpose(),this.w=u.transpose(),this.q=l,this.u=a,this.s=c.transpose().mmul(c),this.xResidual=y,this.yResidual=I,this.betas=_}else this.w=u.transpose(),this.s=c.transpose().mmul(c).sqrt(),s?this.t=c.clone().div(this.s.get(0,0)):this.t=c,this.xResidual=e.sub(c.mmul(u.transpose()))}}q.AbstractMatrix=rt;q.CHO=eo;q.CholeskyDecomposition=eo;q.DistanceMatrix=ai;q.EVD=to;q.EigenvalueDecomposition=to;q.LU=hi;q.LuDecomposition=hi;var Rl=q.Matrix=j;q.MatrixColumnSelectionView=cl;q.MatrixColumnView=hl;q.MatrixFlipColumnView=ll;q.MatrixFlipRowView=ul;q.MatrixRowSelectionView=pl;q.MatrixRowView=dl;q.MatrixSelectionView=Cr;q.MatrixSubView=fl;q.MatrixTransposeView=ml;q.NIPALS=ro;q.Nipals=ro;q.QR=os;q.QrDecomposition=os;q.SVD=Re;var Sl=q.SingularValueDecomposition=Re;q.SymmetricMatrix=oe;q.WrapperMatrix1D=Jn;q.WrapperMatrix2D=Et;q.correlation=El;q.covariance=Ml;var $s=q.default=j;q.determinant=kr;var Al=q.inverse=yl;q.linearDependencies=xl;var Cl=q.pseudoInverse=bl;q.solve=Qn;q.wrap=gl;const It=Rl,kl=Sl;$s.Matrix&&$s.Matrix;const jl=Al,io=Cl;class nr{constructor(e,t,r,s){M(this,"sourcePoints");M(this,"destinationPoints");M(this,"pointCount");M(this,"pointCountMinimum");M(this,"type");if(this.sourcePoints=e,this.destinationPoints=t,this.pointCount=this.sourcePoints.length,this.type=r,this.pointCountMinimum=s,this.pointCount<this.pointCountMinimum)throw new Error("Not enough control points. A "+this.type+" transformation requires a minimum of "+this.pointCountMinimum+" points, but "+this.pointCount+" are given.")}evaluate(e,t="function"){if(t=="function")return this.evaluateFunction(e);if(t=="partialDerivativeX")return this.evaluatePartialDerivativeX(e);if(t=="partialDerivativeY")return this.evaluatePartialDerivativeY(e);throw new Error("Evaluation of type "+t+" not supported")}}class so extends nr{constructor(t,r){super(t,r,"helmert",2);M(this,"helmertParametersMatrix");M(this,"helmertParameters");M(this,"scale");M(this,"rotation");M(this,"translation");const s=It.columnVector(r.flat()),n=It.zeros(2*this.pointCount,4);for(let a=0;a<this.pointCount;a++)n.set(2*a,0,1),n.set(2*a,1,0),n.set(2*a,2,this.sourcePoints[a][0]),n.set(2*a,3,-this.sourcePoints[a][1]),n.set(2*a+1,0,0),n.set(2*a+1,1,1),n.set(2*a+1,2,this.sourcePoints[a][1]),n.set(2*a+1,3,this.sourcePoints[a][0]);const o=io(n);this.helmertParametersMatrix=o.mmul(s),this.helmertParameters=this.helmertParametersMatrix.to1DArray(),this.scale=Math.sqrt(this.helmertParameters[2]**2+this.helmertParameters[3]**2),this.rotation=Math.atan2(this.helmertParameters[3],this.helmertParameters[2]),this.translation=[this.helmertParameters[0],this.helmertParameters[1]]}evaluateFunction(t){if(!this.helmertParameters)throw new Error("Helmert parameters not computed");return[this.helmertParameters[0]+this.helmertParameters[2]*t[0]-this.helmertParameters[3]*t[1],this.helmertParameters[1]+this.helmertParameters[2]*t[1]+this.helmertParameters[3]*t[0]]}evaluatePartialDerivativeX(t){if(!this.helmertParameters)throw new Error("Helmert parameters not computed");return[this.helmertParameters[2],this.helmertParameters[3]]}evaluatePartialDerivativeY(t){if(!this.helmertParameters)throw new Error("Helmert parameters not computed");return[-this.helmertParameters[3],this.helmertParameters[2]]}}class Ll extends nr{constructor(t,r){super(t,r,"straight",2);M(this,"scale");M(this,"sourcePointsCenter");M(this,"destinationPointsCenter");M(this,"translation");const s=new so(this.sourcePoints,this.destinationPoints);if(this.scale=s.scale,!this.scale)throw new Error("Scale could not be computed");this.sourcePointsCenter=this.sourcePoints.reduce((o,a)=>[o[0]+a[0],o[1]+a[1]]).map(o=>o/this.pointCount),this.destinationPointsCenter=this.destinationPoints.reduce((o,a)=>[o[0]+a[0],o[1]+a[1]]).map(o=>o/this.pointCount);const n=this.scale;this.translation=this.destinationPointsCenter.map((o,a)=>o-this.sourcePointsCenter[a]*n)}evaluateFunction(t){if(!this.scale||!this.translation)throw new Error("Straight parameters not computed");return[this.translation[0]+this.scale*t[0],this.translation[1]+this.scale*t[1]]}evaluatePartialDerivativeX(t){if(!this.scale||!this.translation)throw new Error("Straight parameters not computed");return[this.scale,0]}evaluatePartialDerivativeY(t){if(!this.scale||!this.translation)throw new Error("Straight parameters not computed");return[0,this.scale]}}class _i extends nr{constructor(t,r,s){s=s||1;const n=(s+1)*(s+2)/2;super(t,r,"polynomial"+s,n);M(this,"polynomialParametersMatrices");M(this,"polynomialParameters");M(this,"order");M(this,"pointCountMinimum");if(this.order=s,this.pointCountMinimum=n,this.order<1||this.order>3)throw new Error("Only polynomial transformations of order 1, 2 or 3 are supported");const o=[It.columnVector(this.destinationPoints.map(c=>c[0])),It.columnVector(this.destinationPoints.map(c=>c[1]))],a=It.zeros(this.pointCount,this.pointCountMinimum);for(let c=0;c<this.pointCount;c++)switch(this.order){case 1:a.set(c,0,1),a.set(c,1,this.sourcePoints[c][0]),a.set(c,2,this.sourcePoints[c][1]);break;case 2:a.set(c,0,1),a.set(c,1,this.sourcePoints[c][0]),a.set(c,2,this.sourcePoints[c][1]),a.set(c,3,this.sourcePoints[c][0]**2),a.set(c,4,this.sourcePoints[c][1]**2),a.set(c,5,this.sourcePoints[c][0]*this.sourcePoints[c][1]);break;case 3:a.set(c,0,1),a.set(c,1,this.sourcePoints[c][0]),a.set(c,2,this.sourcePoints[c][1]),a.set(c,3,this.sourcePoints[c][0]**2),a.set(c,4,this.sourcePoints[c][1]**2),a.set(c,5,this.sourcePoints[c][0]*this.sourcePoints[c][1]),a.set(c,6,this.sourcePoints[c][0]**3),a.set(c,7,this.sourcePoints[c][1]**3),a.set(c,8,this.sourcePoints[c][0]**2*this.sourcePoints[c][1]),a.set(c,9,this.sourcePoints[c][0]*this.sourcePoints[c][1]**2);break}const h=io(a);this.polynomialParametersMatrices=[h.mmul(o[0]),h.mmul(o[1])],this.polynomialParameters=this.polynomialParametersMatrices.map(c=>c.to1DArray())}evaluateFunction(t){if(!this.polynomialParameters)throw new Error("Polynomial parameters not computed");const r=[0,0];for(let s=0;s<2;s++)switch(this.order){case 1:r[s]+=this.polynomialParameters[s][0]+this.polynomialParameters[s][1]*t[0]+this.polynomialParameters[s][2]*t[1];break;case 2:r[s]+=this.polynomialParameters[s][0]+this.polynomialParameters[s][1]*t[0]+this.polynomialParameters[s][2]*t[1]+this.polynomialParameters[s][3]*t[0]**2+this.polynomialParameters[s][4]*t[1]**2+this.polynomialParameters[s][5]*t[0]*t[1];break;case 3:r[s]+=this.polynomialParameters[s][0]+this.polynomialParameters[s][1]*t[0]+this.polynomialParameters[s][2]*t[1]+this.polynomialParameters[s][3]*t[0]**2+this.polynomialParameters[s][4]*t[1]**2+this.polynomialParameters[s][5]*t[0]*t[1]+this.polynomialParameters[s][6]*t[0]**3+this.polynomialParameters[s][7]*t[1]**3+this.polynomialParameters[s][8]*t[0]**2*t[1]+this.polynomialParameters[s][9]*t[0]*t[1]**2;break}return r}evaluatePartialDerivativeX(t){if(!this.polynomialParameters)throw new Error("Polynomial parameters not computed");const r=[0,0];for(let s=0;s<2;s++)switch(this.order){case 1:r[s]+=this.polynomialParameters[s][1];break;case 2:r[s]+=this.polynomialParameters[s][1]+2*this.polynomialParameters[s][3]*t[0]+this.polynomialParameters[s][5]*t[1];break;case 3:r[s]+=this.polynomialParameters[s][1]+2*this.polynomialParameters[s][3]*t[0]+this.polynomialParameters[s][5]*t[1]+3*this.polynomialParameters[s][6]*t[0]**2+2*this.polynomialParameters[s][8]*t[0]*t[1]+this.polynomialParameters[s][9]*t[1]**2;break}return r}evaluatePartialDerivativeY(t){if(!this.polynomialParameters)throw new Error("Polynomial parameters not computed");const r=[0,0];for(let s=0;s<2;s++)switch(this.order){case 1:r[s]+=this.polynomialParameters[s][2];break;case 2:r[s]+=this.polynomialParameters[s][2]+2*this.polynomialParameters[s][4]*t[1]+this.polynomialParameters[s][5]*t[0];break;case 3:r[s]+=this.polynomialParameters[s][2]+2*this.polynomialParameters[s][4]*t[1]+this.polynomialParameters[s][5]*t[0]+3*this.polynomialParameters[s][7]*t[1]**2+this.polynomialParameters[s][8]*t[0]**2+2*this.polynomialParameters[s][9]*t[0]*t[1];break}return r}}class Ol extends nr{constructor(t,r){super(t,r,"projective",4);M(this,"projectiveParametersMatrix");M(this,"projectiveParameters");const s=It.zeros(2*this.pointCount,9);for(let o=0;o<this.pointCount;o++)s.set(2*o,0,-t[o][0]),s.set(2*o,1,-t[o][1]),s.set(2*o,2,-1),s.set(2*o,3,0),s.set(2*o,4,0),s.set(2*o,5,0),s.set(2*o,6,r[o][0]*t[o][0]),s.set(2*o,7,r[o][0]*t[o][1]),s.set(2*o,8,r[o][0]),s.set(2*o+1,0,0),s.set(2*o+1,1,0),s.set(2*o+1,2,0),s.set(2*o+1,3,-t[o][0]),s.set(2*o+1,4,-t[o][1]),s.set(2*o+1,5,-1),s.set(2*o+1,6,r[o][1]*t[o][0]),s.set(2*o+1,7,r[o][1]*t[o][1]),s.set(2*o+1,8,r[o][1]);const n=new kl(s);this.projectiveParametersMatrix=It.from1DArray(3,3,n.rightSingularVectors.getColumn(8)).transpose(),this.projectiveParameters=this.projectiveParametersMatrix.to2DArray()}evaluateFunction(t){if(!this.projectiveParameters)throw new Error("projective parameters not computed");const r=this.projectiveParameters[0][2]*t[0]+this.projectiveParameters[1][2]*t[1]+this.projectiveParameters[2][2],s=this.projectiveParameters[0][0]*t[0]+this.projectiveParameters[1][0]*t[1]+this.projectiveParameters[2][0],n=this.projectiveParameters[0][1]*t[0]+this.projectiveParameters[1][1]*t[1]+this.projectiveParameters[2][1];return[s/r,n/r]}evaluatePartialDerivativeX(t){if(!this.projectiveParameters)throw new Error("projective parameters not computed");const r=this.projectiveParameters[0][2]*t[0]+this.projectiveParameters[1][2]*t[1]+this.projectiveParameters[2][2],s=this.projectiveParameters[0][0]*t[0]+this.projectiveParameters[1][0]*t[1]+this.projectiveParameters[2][0],n=this.projectiveParameters[0][1]*t[0]+this.projectiveParameters[1][1]*t[1]+this.projectiveParameters[2][1];return[(r*this.projectiveParameters[0][0]-this.projectiveParameters[0][2]*s)/r**2,(r*this.projectiveParameters[0][1]-this.projectiveParameters[0][2]*n)/r**2]}evaluatePartialDerivativeY(t){if(!this.projectiveParameters)throw new Error("projective parameters not computed");const r=this.projectiveParameters[0][2]*t[0]+this.projectiveParameters[1][2]*t[1]+this.projectiveParameters[2][2],s=this.projectiveParameters[0][0]*t[0]+this.projectiveParameters[1][0]*t[1]+this.projectiveParameters[2][0],n=this.projectiveParameters[0][1]*t[0]+this.projectiveParameters[1][1]*t[1]+this.projectiveParameters[2][1];return[(r*this.projectiveParameters[1][0]-this.projectiveParameters[1][2]*s)/r**2,(r*this.projectiveParameters[1][1]-this.projectiveParameters[1][2]*n)/r**2]}}class Dl extends nr{constructor(t,r,s,n,o){super(t,r,"thinPlateSpline",3);M(this,"kernelFunction");M(this,"normFunction");M(this,"weightsMatrices");M(this,"rbfWeights");M(this,"affineWeights");M(this,"epsilon");this.kernelFunction=s,this.normFunction=n;const a=[It.columnVector([...this.destinationPoints,[0,0],[0,0],[0,0]].map(m=>m[0])),It.columnVector([...this.destinationPoints,[0,0],[0,0],[0,0]].map(m=>m[1]))],h=It.zeros(this.pointCount,this.pointCount);for(let m=0;m<this.pointCount;m++)for(let g=0;g<this.pointCount;g++)h.set(m,g,n(this.sourcePoints[m],this.sourcePoints[g]));o===void 0&&(o=h.sum()/(Math.pow(this.pointCount,2)-this.pointCount)),this.epsilon=o;for(let m=0;m<this.pointCount;m++)for(let g=0;g<this.pointCount;g++)h.set(m,g,s(h.get(m,g),{epsilon:o}));const c=It.zeros(this.pointCount,3),l=It.zeros(this.pointCount+3,this.pointCount+3);for(let m=0;m<this.pointCount;m++)c.set(m,0,1),c.set(m,1,this.sourcePoints[m][0]),c.set(m,2,this.sourcePoints[m][1]);for(let m=0;m<this.pointCount+3;m++)for(let g=0;g<this.pointCount+3;g++)m<this.pointCount&&g<this.pointCount?l.set(m,g,h.get(m,g)):m>=this.pointCount&&g<this.pointCount?l.set(m,g,c.transpose().get(m-this.pointCount,g)):m<this.pointCount&&g>=this.pointCount&&l.set(m,g,c.get(m,g-this.pointCount));const u=jl(l);this.weightsMatrices=[u.mmul(a[0]),u.mmul(a[1])],this.rbfWeights=this.weightsMatrices.map(m=>m.selection([...Array(this.pointCount).keys()],[0]).to1DArray()),this.affineWeights=this.weightsMatrices.map(m=>m.selection([0,1,2].map(g=>g+this.pointCount),[0]).to1DArray())}evaluateFunction(t){if(!this.rbfWeights||!this.affineWeights)throw new Error("Weights not computed");const r=this.sourcePoints.map(n=>this.normFunction(t,n)),s=[0,0];for(let n=0;n<2;n++)s[n]=r.reduce((o,a,h)=>o+this.kernelFunction(a,{epsilon:this.epsilon})*this.rbfWeights[n][h],0),s[n]+=this.affineWeights[n][0]+this.affineWeights[n][1]*t[0]+this.affineWeights[n][2]*t[1];return s}evaluatePartialDerivativeX(t){if(!this.rbfWeights||!this.affineWeights)throw new Error("Weights not computed");const r=this.sourcePoints.map(n=>this.normFunction(t,n)),s=[0,0];for(let n=0;n<2;n++)s[n]=r.reduce((o,a,h)=>o+(a==0?0:this.kernelFunction(a,{derivative:1,epsilon:this.epsilon})*((t[0]-this.sourcePoints[h][0])/a)*this.rbfWeights[n][h]),0),s[n]+=this.affineWeights[n][1];return s}evaluatePartialDerivativeY(t){if(!this.rbfWeights||!this.affineWeights)throw new Error("Weights not computed");const r=this.sourcePoints.map(n=>this.normFunction(t,n)),s=[0,0];for(let n=0;n<2;n++)s[n]=r.reduce((o,a,h)=>o+(a==0?0:this.kernelFunction(a,{derivative:1,epsilon:this.epsilon})*((t[1]-this.sourcePoints[h][1])/a)*this.rbfWeights[n][h]),0),s[n]+=this.affineWeights[n][2];return s}}function Nl(i,e){if(e.derivative){if(e.derivative==1)return i===0?0:i+2*i*Math.log(i);throw new Error("Derivate of order "+e.derivative+" not implemented")}else return i===0?0:Math.pow(i,2)*Math.log(i)}function Fl(i,e){const t=[e[0]-i[0],e[1]-i[1]];return Math.sqrt(t[0]**2+t[1]**2)}function Q(i,e,t){return{maxOffsetRatio:0,maxDepth:0,destinationIsGeographic:!1,sourceIsGeographic:!1,inputIsMultiGeometry:!1,differentHandedness:!1,evaluationType:"function",...t,...e,...i}}function Er(i,e,t){e=ri(e);const r=e.map(o=>({source:o,destination:i.transformForward(o)})),s=ci(r,!1),n=no(i,s,t);return li(n,!0).map(o=>o.destination)}function _r(i,e,t){e=ri(e);const r=e.map(o=>({source:i.transformBackward(o),destination:o})),s=ci(r,!1),n=oo(i,s,t);return li(n,!0).map(o=>o.source)}function Gl(i,e,t){e=Ki(e);const r=e.map(o=>({source:o,destination:i.transformForward(o)})),s=ci(r,!0),n=no(i,s,t);return li(n,!1).map(o=>o.destination)}function Bl(i,e,t){e=Ki(e);const r=e.map(o=>({source:i.transformBackward(o),destination:o})),s=ci(r,!0),n=oo(i,s,t);return li(n,!1).map(o=>o.source)}function Tr(i,e,t){return e.map(r=>Gl(i,r,t))}function Pr(i,e,t){return e.map(r=>Bl(i,r,t))}function ci(i,e=!1){const t=i.length-(e?0:1),r=[];for(let s=0;s<t;s++)r.push({from:i[s],to:i[(s+1)%i.length]});return r}function li(i,e=!1){const t=i.map(r=>r.from);return e&&t.push(i[i.length-1].to),t}function no(i,e,t){return t.maxDepth<=0?e:e.map(r=>$i(i,r,t,0)).flat(1)}function oo(i,e,t){return t.maxDepth<=0?e:e.map(r=>Xi(i,r,t,0)).flat(1)}function $i(i,e,t,r){if(r>=t.maxDepth)return e;const s=(t.sourceIsGeographic?(c,l)=>Hr(c,l).geometry.coordinates:Lr)(e.from.source,e.to.source),n=(t.destinationIsGeographic?(c,l)=>Hr(c,l).geometry.coordinates:Lr)(e.from.destination,e.to.destination),o=i.transformForward(s),a=t.destinationIsGeographic?is:bt,h=a(e.from.destination,e.to.destination);if(a(n,o)/h>t.maxOffsetRatio&&h>0){const c={source:s,destination:o};return[$i(i,{from:e.from,to:c},t,r+1),$i(i,{from:c,to:e.to},t,r+1)].flat(1)}else return e}function Xi(i,e,t,r){if(r>=t.maxDepth)return e;const s=(t.destinationIsGeographic?(c,l)=>Hr(c,l).geometry.coordinates:Lr)(e.from.destination,e.to.destination),n=(t.sourceIsGeographic?(c,l)=>Hr(c,l).geometry.coordinates:Lr)(e.from.source,e.to.source),o=i.transformBackward(s),a=t.sourceIsGeographic?is:bt,h=a(e.from.source,e.to.source);if(a(n,o)/h>t.maxOffsetRatio&&h>0){const c={source:o,destination:s};return[Xi(i,{from:e.from,to:c},t,r+1),Xi(i,{from:c,to:e.to},t,r+1)].flat(1)}else return e}class Ti{constructor(e,t="polynomial",r){M(this,"gcps");M(this,"sourcePoints");M(this,"destinationPoints");M(this,"type");M(this,"options");M(this,"forwardTransformation");M(this,"backwardTransformation");if(r&&(this.options=r),e.length===0)throw new Error("No control points");this.gcps=e.map(s=>{if("resource"in s&&"geo"in s)return{source:s.resource,destination:s.geo};if("source"in s&&"destination"in s)return s;throw new Error("Unsupported GCP type")}),this.sourcePoints=this.gcps.map(s=>s.source),this.destinationPoints=this.gcps.map(s=>s.destination),this.type=t}createForwardTransformation(){this.forwardTransformation=this.computeTransformation(this.sourcePoints.map(e=>this.assureEqualHandedness(e)),this.destinationPoints)}createBackwardTransformation(){this.backwardTransformation=this.computeTransformation(this.destinationPoints,this.sourcePoints.map(e=>this.assureEqualHandedness(e)))}transformForward(e,t){if(!Q(t,this.options).inputIsMultiGeometry){if(gt(e))return this.forwardTransformation||this.createForwardTransformation(),this.forwardTransformation.evaluate(this.assureEqualHandedness(e),Q(t,this.options).evaluationType);if(zt(e))return this.transformForward(Le(e),t);if(St(e))return Er(this,e,Q(t,this.options));if(Wt(e))return Er(this,Oe(e),Q(t,this.options,{sourceIsGeographic:!0}));if(At(e))return Tr(this,e,Q(t,this.options));if(Zt(e))return Tr(this,De(e),Q(t,this.options,{sourceIsGeographic:!0}))}if(t&&(t.inputIsMultiGeometry=!1),Gt(e))return e.map(r=>this.transformForward(r,t));if(Vt(e))return pr(e).map(r=>this.transformForward(r,t));if(Bt(e))return e.map(r=>this.transformForward(r,t));if(qt(e))return fr(e).map(r=>this.transformForward(r,t));if(Ut(e))return e.map(r=>this.transformForward(r,t));if($t(e))return mr(e).map(r=>this.transformForward(r,t));throw new Error("Input type not supported")}transformForwardAsGeojson(e,t){if(!Q(t,this.options).inputIsMultiGeometry){if(gt(e))return lr(this.transformForward(e));if(zt(e))return lr(this.transformForward(Le(e)));if(St(e))return ur(Er(this,e,Q(t,this.options,{destinationIsGeographic:!0})));if(Wt(e))return ur(Er(this,Oe(e),Q(t,this.options,{sourceIsGeographic:!0,destinationIsGeographic:!0})));if(At(e))return dr(Tr(this,e,Q(t,this.options,{destinationIsGeographic:!0})));if(Zt(e))return dr(Tr(this,De(e),Q(t,this.options,{sourceIsGeographic:!0,destinationIsGeographic:!0})))}if(t&&(t.inputIsMultiGeometry=!1),Gt(e))return gr(e.map(r=>this.transformForwardAsGeojson(r,t)));if(Vt(e))return gr(pr(e).map(r=>this.transformForwardAsGeojson(r,t)));if(Bt(e))return yr(e.map(r=>this.transformForwardAsGeojson(r,t)));if(qt(e))return yr(fr(e).map(r=>this.transformForwardAsGeojson(r,t)));if(Ut(e))return vr(e.map(r=>this.transformForwardAsGeojson(r,t)));if($t(e))return vr(mr(e).map(r=>this.transformForwardAsGeojson(r,t)));throw new Error("Input type not supported")}transformBackward(e,t){if(!Q(t,this.options).inputIsMultiGeometry){if(gt(e))return this.backwardTransformation||this.createBackwardTransformation(),this.assureEqualHandedness(this.backwardTransformation.evaluate(e));if(zt(e))return this.transformBackward(Le(e));if(St(e))return _r(this,e,Q(t,this.options));if(Wt(e))return _r(this,Oe(e),Q(t,this.options,{destinationIsGeographic:!0}));if(At(e))return Pr(this,e,Q(t,this.options));if(Zt(e))return Pr(this,De(e),Q(t,this.options,{destinationIsGeographic:!0}))}if(t&&(t.inputIsMultiGeometry=!1),Gt(e))return e.map(r=>this.transformBackward(r,t));if(Vt(e))return pr(e).map(r=>this.transformBackward(r,t));if(Bt(e))return e.map(r=>this.transformBackward(r,t));if(qt(e))return fr(e).map(r=>this.transformBackward(r,t));if(Ut(e))return e.map(r=>this.transformBackward(r,t));if($t(e))return mr(e).map(r=>this.transformBackward(r,t));throw new Error("Input type not supported")}transformBackwardAsGeojson(e,t){if(!Q(t,this.options).inputIsMultiGeometry){if(gt(e))return lr(this.transformBackward(e));if(zt(e))return lr(this.transformBackward(Le(e)));if(St(e))return ur(_r(this,e,Q(t,this.options,{sourceIsGeographic:!0})));if(Wt(e))return ur(_r(this,Oe(e),Q(t,this.options,{sourceIsGeographic:!0,destinationIsGeographic:!0})));if(At(e))return dr(Pr(this,e,Q(t,this.options,{sourceIsGeographic:!0})));if(Zt(e))return dr(Pr(this,De(e),Q(t,this.options,{sourceIsGeographic:!0,destinationIsGeographic:!0})))}if(t&&(t.inputIsMultiGeometry=!1),Gt(e))return gr(e.map(r=>this.transformBackwardAsGeojson(r,t)));if(Vt(e))return gr(pr(e).map(r=>this.transformBackwardAsGeojson(r,t)));if(Bt(e))return yr(e.map(r=>this.transformBackwardAsGeojson(r,t)));if(qt(e))return yr(fr(e).map(r=>this.transformBackwardAsGeojson(r,t)));if(Ut(e))return vr(e.map(r=>this.transformBackwardAsGeojson(r,t)));if($t(e))return vr(mr(e).map(r=>this.transformBackwardAsGeojson(r,t)));throw new Error("Input type not supported")}transformToGeo(e,t){if(!Q(t,this.options).inputIsMultiGeometry){if(gt(e))return this.transformForward(e,t);if(zt(e))return this.transformForward(e,t);if(St(e))return this.transformForward(e,t);if(Wt(e))return this.transformForward(e,t);if(At(e))return this.transformForward(e,t);if(Zt(e))return this.transformForward(e,t)}if(t&&(t.inputIsMultiGeometry=!1),Gt(e))return this.transformForward(e,t);if(Vt(e))return this.transformForward(e,t);if(Bt(e))return this.transformForward(e,t);if(qt(e))return this.transformForward(e,t);if(Ut(e))return this.transformForward(e,t);if($t(e))return this.transformForward(e,t);throw new Error("Input type not supported")}transformToGeoAsGeojson(e,t){if(!Q(t,this.options).inputIsMultiGeometry){if(gt(e))return this.transformForwardAsGeojson(e,t);if(zt(e))return this.transformForwardAsGeojson(e,t);if(St(e))return this.transformForwardAsGeojson(e,t);if(Wt(e))return this.transformForwardAsGeojson(e,t);if(At(e))return this.transformForwardAsGeojson(e,t);if(Zt(e))return this.transformForwardAsGeojson(e,t)}if(t&&(t.inputIsMultiGeometry=!1),Gt(e))return this.transformForwardAsGeojson(e,t);if(Vt(e))return this.transformForwardAsGeojson(e,t);if(Bt(e))return this.transformForwardAsGeojson(e,t);if(qt(e))return this.transformForwardAsGeojson(e,t);if(Ut(e))return this.transformForwardAsGeojson(e,t);if($t(e))return this.transformForwardAsGeojson(e,t);throw new Error("Input type not supported")}transformToResource(e,t){if(!Q(t,this.options).inputIsMultiGeometry){if(gt(e))return this.transformBackward(e,t);if(zt(e))return this.transformBackward(e,t);if(St(e))return this.transformBackward(e,t);if(Wt(e))return this.transformBackward(e,t);if(At(e))return this.transformBackward(e,t);if(Zt(e))return this.transformBackward(e,t)}if(t&&(t.inputIsMultiGeometry=!1),Gt(e))return this.transformBackward(e,t);if(Vt(e))return this.transformBackward(e,t);if(Bt(e))return this.transformBackward(e,t);if(qt(e))return this.transformBackward(e,t);if(Ut(e))return this.transformBackward(e,t);if($t(e))return this.transformBackward(e,t);throw new Error("Input type not supported")}transformToResourceAsGeojson(e,t){if(!Q(t,this.options).inputIsMultiGeometry){if(gt(e))return this.transformBackwardAsGeojson(e,t);if(zt(e))return this.transformBackwardAsGeojson(e,t);if(St(e))return this.transformBackwardAsGeojson(e,t);if(Wt(e))return this.transformBackwardAsGeojson(e,t);if(At(e))return this.transformBackwardAsGeojson(e,t);if(Zt(e))return this.transformBackwardAsGeojson(e,t)}if(t&&(t.inputIsMultiGeometry=!1),Gt(e))return this.transformBackwardAsGeojson(e,t);if(Vt(e))return this.transformBackwardAsGeojson(e,t);if(Bt(e))return this.transformBackwardAsGeojson(e,t);if(qt(e))return this.transformBackwardAsGeojson(e,t);if(Ut(e))return this.transformBackwardAsGeojson(e,t);if($t(e))return this.transformBackwardAsGeojson(e,t);throw new Error("Input type not supported")}transformSvgToGeojson(e,t){if(e.type==="circle")return this.transformForwardAsGeojson(e.coordinates);if(e.type==="line")return this.transformForwardAsGeojson(e.coordinates,t);if(e.type==="polyline")return this.transformForwardAsGeojson(e.coordinates,t);if(e.type==="rect")return this.transformForwardAsGeojson([e.coordinates],t);if(e.type==="polygon")return this.transformForwardAsGeojson([e.coordinates],t);throw new Error("Unsupported SVG geometry")}transformSvgStringToGeojsonFeatureCollection(e,t){const r=[];for(const s of Fa(e)){const n=this.transformSvgToGeojson(s,t);r.push(n)}return Ta(r)}transformGeojsonToSvg(e,t){if(e.type==="Point")return{type:"circle",coordinates:this.transformBackward(e)};if(e.type==="LineString")return{type:"polyline",coordinates:this.transformBackward(e,t)};if(e.type==="Polygon")return{type:"polygon",coordinates:this.transformBackward(e,t)[0]};throw new Error("Unsupported GeoJSON geometry")}transformGeojsonFeatureCollectionToSvgString(e,t){const r=[];for(const s of Ia(e)){const n=this.transformGeojsonToSvg(s,t);r.push(n)}return Ba(r)}assureEqualHandedness(e){var t;return(t=this.options)!=null&&t.differentHandedness?ma(e):e}computeTransformation(e,t){if(this.type==="straight")return new Ll(e,t);if(this.type==="helmert")return new so(e,t);if(this.type==="polynomial1"||this.type==="polynomial")return new _i(e,t);if(this.type==="polynomial2")return new _i(e,t,2);if(this.type==="polynomial3")return new _i(e,t,3);if(this.type==="projective")return new Ol(e,t);if(this.type==="thinPlateSpline")return new Dl(e,t,Nl,Fl);throw new Error(`Unsupported transformation type: ${this.type}`)}}const ao=["log2sigma","twoOmega","airyKavr","signDetJ","thetaa"];function Ul(i,e,t,r=1){if(!t)return 0;const s=i[0]**2+i[1]**2,n=e[0]**2+e[1]**2,o=i[0]*e[0]+i[1]*e[1],a=Math.sqrt(.5*(s+n+Math.sqrt((s-n)**2+4*o**2))),h=Math.sqrt(.5*(s+n-Math.sqrt((s-n)**2+4*o**2))),c=Math.atan(i[1]/i[0]),l=Math.sign(-o)*Math.asin(Math.sqrt((1-a**2/s)/(1-(a/h)**2)));switch(ao.indexOf(t)){case 0:return(Math.log(a*h)-2*Math.log(r))/Math.log(2);case 1:return 2*Math.asin((a-h)/(a+h));case 2:return .5*(Math.log(a/r)**2+Math.log(h/r)**2);case 3:return Math.sign(i[0]*e[1]-i[1]*e[0]);case 4:return c-l;default:throw new Error("Distortion "+t+" not supported")}}var k=(i=>(i.GEOREFERENCEANNOTATIONADDED="georeferenceannotationadded",i.GEOREFERENCEANNOTATIONREMOVED="georeferenceannotationremoved",i.WARPEDMAPADDED="warpedmapadded",i.WARPEDMAPREMOVED="warpedmapremoved",i.WARPEDMAPENTER="warpedmapenter",i.WARPEDMAPLEAVE="warpedmapleave",i.IMAGEINFOLOADED="imageinfoloaded",i.TILEFETCHED="tilefetched",i.TILEFETCHERROR="tilefetcherror",i.MAPTILELOADED="maptileloaded",i.MAPTILEREMOVED="maptileremoved",i.FIRSTMAPTILELOADED="firstmaptileloaded",i.ALLREQUESTEDTILESLOADED="allrequestedtilesloaded",i.TEXTURESUPDATED="texturesupdated",i.ZINDICESCHANGES="zindiceschanged",i.RESOURCEMASKUPDATED="resourcemaskupdated",i.VISIBILITYCHANGED="visibilitychanged",i.TRANSFORMATIONCHANGED="transformationchanged",i.DISTORTIONCHANGED="distortionchanged",i.CHANGED="changed",i.CLEARED="cleared",i))(k||{});let Z=class extends Event{constructor(e,t){super(e);M(this,"data");this.data=t}};const Pi={maxOffsetRatio:.05,maxDepth:2,differentHandedness:!0},ho=!0;function zl(){return{visible:ho}}class Wl extends EventTarget{constructor(t,r,s){var n,o;super();M(this,"mapId");M(this,"georeferencedMap");M(this,"gcps");M(this,"projectedGcps");M(this,"resourceMask");M(this,"resourceMaskBbox");M(this,"resourceMaskRectangle");M(this,"resourceFullMask");M(this,"resourceFullMaskBbox");M(this,"resourceFullMaskRectangle");M(this,"imageInformations");M(this,"imageId");M(this,"parsedImage");M(this,"loadingImageInfo");M(this,"fetchFn");M(this,"visible");M(this,"transformationType");M(this,"transformer");M(this,"projectedTransformer");M(this,"transformerByTransformationType",new Map);M(this,"projectedTransformerByTransformationType",new Map);M(this,"geoMask");M(this,"geoMaskBbox");M(this,"geoMaskRectangle");M(this,"geoFullMask");M(this,"geoFullMaskBbox");M(this,"geoFullMaskRectangle");M(this,"projectedGeoMask");M(this,"projectedGeoMaskBbox");M(this,"projectedGeoMaskRectangle");M(this,"projectedGeoFullMask");M(this,"projectedGeoFullMaskBbox");M(this,"projectedGeoFullMaskRectangle");M(this,"resourceToProjectedGeoScale");M(this,"distortionMeasure");M(this,"bestScaleFactor");M(this,"resourceViewportRing",[]);M(this,"resourceViewportRingBbox");s={...zl(),...s},this.mapId=t,this.georeferencedMap=r,this.gcps=this.georeferencedMap.gcps,this.projectedGcps=this.gcps.map(({resource:a,geo:h})=>({resource:a,geo:fe(h)})),this.resourceMask=this.georeferencedMap.resourceMask,this.updateResourceMaskProperties(),this.resourceFullMask=[[0,0],[this.georeferencedMap.resource.width,0],[this.georeferencedMap.resource.width,this.georeferencedMap.resource.height],[0,this.georeferencedMap.resource.height]],this.resourceFullMaskBbox=dt(this.resourceFullMask),this.resourceFullMaskRectangle=Or(this.resourceFullMaskBbox),this.imageInformations=s.imageInformations,this.loadingImageInfo=!1,this.visible=s.visible||ho,this.fetchFn=s.fetchFn,this.transformationType=((n=s.transformation)==null?void 0:n.type)||((o=this.georeferencedMap.transformation)==null?void 0:o.type)||"polynomial",this.updateTransformerProperties()}getViewportMask(t){return this.projectedGeoMask.map(r=>we(t.projectedGeoToViewportTransform,r))}getViewportMaskBbox(t){return dt(this.getViewportMask(t))}getViewportMaskRectangle(t){return this.projectedGeoMaskRectangle.map(r=>we(t.projectedGeoToViewportTransform,r))}getViewportFullMask(t){return this.projectedGeoFullMask.map(r=>we(t.projectedGeoToViewportTransform,r))}getViewportFullMaskBbox(t){return dt(this.getViewportFullMask(t))}getViewportFullMaskRectangle(t){return this.projectedGeoFullMaskRectangle.map(r=>we(t.projectedGeoToViewportTransform,r))}getResourceToViewportScale(t){return Is(this.resourceMaskRectangle,this.getViewportMaskRectangle(t))}getResourceToCanvasScale(t){return this.getResourceToViewportScale(t)/t.devicePixelRatio}getReferenceScale(){const t=Ar(this.projectedTransformerByTransformationType,"helmert",()=>new Ti(this.projectedGcps,"helmert",Pi));return t.forwardTransformation||t.createForwardTransformation(),t.forwardTransformation.scale}setResourceViewportRing(t){this.resourceViewportRing=t,this.resourceViewportRingBbox=dt(t)}setResourceMask(t){this.resourceMask=t,this.updateResourceMaskProperties(),this.updateGeoMask(),this.updateProjectedGeoMask(),this.updateResourceToProjectedGeoScale()}setTransformationType(t){this.transformationType=t,this.updateTransformerProperties()}setDistortionMeasure(t){this.distortionMeasure=t}setGcps(t){this.gcps=t,this.updateTransformerProperties(!1)}setBestScaleFactor(t){const r=this.bestScaleFactor!=t;return r&&(this.bestScaleFactor=t),r}hasImageInfo(){return this.imageId!==void 0&&this.parsedImage!==void 0}async loadImageInfo(){var t,r;try{this.loadingImageInfo=!0;const s=this.georeferencedMap.resource.id;let n;(t=this.imageInformations)!=null&&t.get(s)?n=this.imageInformations.get(s):(n=await ca(s,void 0,this.fetchFn),(r=this.imageInformations)==null||r.set(s,n)),this.parsedImage=rs.parse(n),this.imageId=await fn(s),this.dispatchEvent(new Z(k.IMAGEINFOLOADED))}catch(s){throw this.loadingImageInfo=!1,s}finally{this.loadingImageInfo=!1}}dispose(){}updateResourceMaskProperties(){this.resourceMaskBbox=dt(this.resourceMask),this.resourceMaskRectangle=Or(this.resourceMaskBbox)}updateTransformerProperties(t=!0){this.updateTransformer(t),this.updateProjectedTransformer(t),this.updateGeoMask(),this.updateFullGeoMask(),this.updateProjectedGeoMask(),this.updateProjectedFullGeoMask(),this.updateResourceToProjectedGeoScale()}updateTransformer(t=!0){this.transformer=Ar(this.transformerByTransformationType,this.transformationType,()=>new Ti(this.gcps,this.transformationType,Pi),t)}updateProjectedTransformer(t=!0){this.projectedTransformer=Ar(this.projectedTransformerByTransformationType,this.transformationType,()=>new Ti(this.projectedGcps,this.transformationType,Pi),t)}updateGeoMask(){this.geoMask=this.transformer.transformForwardAsGeojson([this.resourceMask]),this.geoMaskBbox=dt(this.geoMask),this.geoMaskRectangle=this.transformer.transformForward([this.resourceMaskRectangle],{maxDepth:0})[0]}updateFullGeoMask(){this.geoFullMask=this.transformer.transformForwardAsGeojson([this.resourceFullMask]),this.geoFullMaskBbox=dt(this.geoFullMask),this.geoFullMaskRectangle=this.transformer.transformForward([this.resourceFullMaskRectangle],{maxDepth:0})[0]}updateProjectedGeoMask(){this.projectedGeoMask=this.projectedTransformer.transformForward([this.resourceMask])[0],this.projectedGeoMaskBbox=dt(this.projectedGeoMask),this.projectedGeoMaskRectangle=this.projectedTransformer.transformForward([this.resourceMaskRectangle],{maxDepth:0})[0]}updateProjectedFullGeoMask(){this.projectedGeoFullMask=this.projectedTransformer.transformForward([this.resourceFullMask])[0],this.projectedGeoFullMaskBbox=dt(this.projectedGeoFullMask),this.projectedGeoFullMaskRectangle=this.projectedTransformer.transformForward([this.resourceFullMaskRectangle],{maxDepth:0})[0]}updateResourceToProjectedGeoScale(){this.resourceToProjectedGeoScale=Is(this.resourceMaskRectangle,this.projectedGeoMaskRectangle)}}function Zl(i){return Math.sqrt(Math.pow(i[1][0]-i[0][0],2)+Math.pow(i[1][1]-i[0][1],2))}function Vl(i){return Math.atan2(i[1][1]-i[0][1],i[1][0]-i[0][0])}function ql(i,e,t){return[i[0]+Math.cos(t)*e,i[1]+Math.sin(t)*e]}function $l(i,e){let t=i[0];const r=[t];for(;Zl([t,i[1]])>e;){const s=ql(t,e,Vl(i));r.push(s),t=s}return r}function Xl(i,e){i=[...i,i[0]];let t=[];for(let r=0;r<i.length-1;r++)t=t.concat($l([i[r],i[r+1]],e));return t}function Hl(i,e){const t=[],r=dt(i);for(let s=r[0]+e,n=0;s<=r[2];n++,s+=e)for(let o=r[1]+e,a=0;o<=r[3];a++,o+=e)t.push([s,o]);return t}function Yl(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var co={exports:{}},lo=Kl,Xs=+(Math.pow(2,27)+1);function Kl(i,e,t){var r=i*e,s=Xs*i,n=s-i,o=s-n,a=i-o,h=Xs*e,c=h-e,l=h-c,u=e-l,m=r-o*l,g=m-a*l,y=g-o*u,_=a*u-y;return t?(t[0]=_,t[1]=r,t):[_,r]}var Jl=tu;function Ql(i,e){var t=i+e,r=t-i,s=t-r,n=e-r,o=i-s,a=o+n;return a?[a,t]:[t]}function tu(i,e){var t=i.length|0,r=e.length|0;if(t===1&&r===1)return Ql(i[0],e[0]);var s=t+r,n=new Array(s),o=0,a=0,h=0,c=Math.abs,l=i[a],u=c(l),m=e[h],g=c(m),y,_;u<g?(_=l,a+=1,a<t&&(l=i[a],u=c(l))):(_=m,h+=1,h<r&&(m=e[h],g=c(m))),a<t&&u<g||h>=r?(y=l,a+=1,a<t&&(l=i[a],u=c(l))):(y=m,h+=1,h<r&&(m=e[h],g=c(m)));for(var I=y+_,w=I-y,R=_-w,d=R,f=I,x,S,T,E,p;a<t&&h<r;)u<g?(y=l,a+=1,a<t&&(l=i[a],u=c(l))):(y=m,h+=1,h<r&&(m=e[h],g=c(m))),_=d,I=y+_,w=I-y,R=_-w,R&&(n[o++]=R),x=f+I,S=x-f,T=x-S,E=I-S,p=f-T,d=p+E,f=x;for(;a<t;)y=l,_=d,I=y+_,w=I-y,R=_-w,R&&(n[o++]=R),x=f+I,S=x-f,T=x-S,E=I-S,p=f-T,d=p+E,f=x,a+=1,a<t&&(l=i[a]);for(;h<r;)y=m,_=d,I=y+_,w=I-y,R=_-w,R&&(n[o++]=R),x=f+I,S=x-f,T=x-S,E=I-S,p=f-T,d=p+E,f=x,h+=1,h<r&&(m=e[h]);return d&&(n[o++]=d),f&&(n[o++]=f),o||(n[o++]=0),n.length=o,n}var eu=ru;function ru(i,e,t){var r=i+e,s=r-i,n=r-s,o=e-s,a=i-n;return t?(t[0]=a+o,t[1]=r,t):[a+o,r]}var Ii=lo,iu=eu,su=nu;function nu(i,e){var t=i.length;if(t===1){var r=Ii(i[0],e);return r[0]?r:[r[1]]}var s=new Array(2*t),n=[.1,.1],o=[.1,.1],a=0;Ii(i[0],e,n),n[0]&&(s[a++]=n[0]);for(var h=1;h<t;++h){Ii(i[h],e,o);var c=n[1];iu(c,o[0],n),n[0]&&(s[a++]=n[0]);var l=o[1],u=n[1],m=l+u,g=m-l,y=u-g;n[1]=m,y&&(s[a++]=y)}return n[1]&&(s[a++]=n[1]),a===0&&(s[a++]=0),s.length=a,s}var ou=hu;function au(i,e){var t=i+e,r=t-i,s=t-r,n=e-r,o=i-s,a=o+n;return a?[a,t]:[t]}function hu(i,e){var t=i.length|0,r=e.length|0;if(t===1&&r===1)return au(i[0],-e[0]);var s=t+r,n=new Array(s),o=0,a=0,h=0,c=Math.abs,l=i[a],u=c(l),m=-e[h],g=c(m),y,_;u<g?(_=l,a+=1,a<t&&(l=i[a],u=c(l))):(_=m,h+=1,h<r&&(m=-e[h],g=c(m))),a<t&&u<g||h>=r?(y=l,a+=1,a<t&&(l=i[a],u=c(l))):(y=m,h+=1,h<r&&(m=-e[h],g=c(m)));for(var I=y+_,w=I-y,R=_-w,d=R,f=I,x,S,T,E,p;a<t&&h<r;)u<g?(y=l,a+=1,a<t&&(l=i[a],u=c(l))):(y=m,h+=1,h<r&&(m=-e[h],g=c(m))),_=d,I=y+_,w=I-y,R=_-w,R&&(n[o++]=R),x=f+I,S=x-f,T=x-S,E=I-S,p=f-T,d=p+E,f=x;for(;a<t;)y=l,_=d,I=y+_,w=I-y,R=_-w,R&&(n[o++]=R),x=f+I,S=x-f,T=x-S,E=I-S,p=f-T,d=p+E,f=x,a+=1,a<t&&(l=i[a]);for(;h<r;)y=m,_=d,I=y+_,w=I-y,R=_-w,R&&(n[o++]=R),x=f+I,S=x-f,T=x-S,E=I-S,p=f-T,d=p+E,f=x,h+=1,h<r&&(m=-e[h]);return d&&(n[o++]=d),f&&(n[o++]=f),o||(n[o++]=0),n.length=o,n}(function(i){var e=lo,t=Jl,r=su,s=ou,n=5,o=11102230246251565e-32,a=(3+16*o)*o,h=(7+56*o)*o;function c(d,f,x,S){return function(T,E,p){var b=d(d(f(E[1],p[0]),f(-p[1],E[0])),d(f(T[1],E[0]),f(-E[1],T[0]))),P=d(f(T[1],p[0]),f(-p[1],T[0])),A=S(b,P);return A[A.length-1]}}function l(d,f,x,S){return function(T,E,p,b){var P=d(d(x(d(f(p[1],b[0]),f(-b[1],p[0])),E[2]),d(x(d(f(E[1],b[0]),f(-b[1],E[0])),-p[2]),x(d(f(E[1],p[0]),f(-p[1],E[0])),b[2]))),d(x(d(f(E[1],b[0]),f(-b[1],E[0])),T[2]),d(x(d(f(T[1],b[0]),f(-b[1],T[0])),-E[2]),x(d(f(T[1],E[0]),f(-E[1],T[0])),b[2])))),A=d(d(x(d(f(p[1],b[0]),f(-b[1],p[0])),T[2]),d(x(d(f(T[1],b[0]),f(-b[1],T[0])),-p[2]),x(d(f(T[1],p[0]),f(-p[1],T[0])),b[2]))),d(x(d(f(E[1],p[0]),f(-p[1],E[0])),T[2]),d(x(d(f(T[1],p[0]),f(-p[1],T[0])),-E[2]),x(d(f(T[1],E[0]),f(-E[1],T[0])),p[2])))),$=S(P,A);return $[$.length-1]}}function u(d,f,x,S){return function(T,E,p,b,P){var A=d(d(d(x(d(x(d(f(b[1],P[0]),f(-P[1],b[0])),p[2]),d(x(d(f(p[1],P[0]),f(-P[1],p[0])),-b[2]),x(d(f(p[1],b[0]),f(-b[1],p[0])),P[2]))),E[3]),d(x(d(x(d(f(b[1],P[0]),f(-P[1],b[0])),E[2]),d(x(d(f(E[1],P[0]),f(-P[1],E[0])),-b[2]),x(d(f(E[1],b[0]),f(-b[1],E[0])),P[2]))),-p[3]),x(d(x(d(f(p[1],P[0]),f(-P[1],p[0])),E[2]),d(x(d(f(E[1],P[0]),f(-P[1],E[0])),-p[2]),x(d(f(E[1],p[0]),f(-p[1],E[0])),P[2]))),b[3]))),d(x(d(x(d(f(p[1],b[0]),f(-b[1],p[0])),E[2]),d(x(d(f(E[1],b[0]),f(-b[1],E[0])),-p[2]),x(d(f(E[1],p[0]),f(-p[1],E[0])),b[2]))),-P[3]),d(x(d(x(d(f(b[1],P[0]),f(-P[1],b[0])),E[2]),d(x(d(f(E[1],P[0]),f(-P[1],E[0])),-b[2]),x(d(f(E[1],b[0]),f(-b[1],E[0])),P[2]))),T[3]),x(d(x(d(f(b[1],P[0]),f(-P[1],b[0])),T[2]),d(x(d(f(T[1],P[0]),f(-P[1],T[0])),-b[2]),x(d(f(T[1],b[0]),f(-b[1],T[0])),P[2]))),-E[3])))),d(d(x(d(x(d(f(E[1],P[0]),f(-P[1],E[0])),T[2]),d(x(d(f(T[1],P[0]),f(-P[1],T[0])),-E[2]),x(d(f(T[1],E[0]),f(-E[1],T[0])),P[2]))),b[3]),d(x(d(x(d(f(E[1],b[0]),f(-b[1],E[0])),T[2]),d(x(d(f(T[1],b[0]),f(-b[1],T[0])),-E[2]),x(d(f(T[1],E[0]),f(-E[1],T[0])),b[2]))),-P[3]),x(d(x(d(f(p[1],b[0]),f(-b[1],p[0])),E[2]),d(x(d(f(E[1],b[0]),f(-b[1],E[0])),-p[2]),x(d(f(E[1],p[0]),f(-p[1],E[0])),b[2]))),T[3]))),d(x(d(x(d(f(p[1],b[0]),f(-b[1],p[0])),T[2]),d(x(d(f(T[1],b[0]),f(-b[1],T[0])),-p[2]),x(d(f(T[1],p[0]),f(-p[1],T[0])),b[2]))),-E[3]),d(x(d(x(d(f(E[1],b[0]),f(-b[1],E[0])),T[2]),d(x(d(f(T[1],b[0]),f(-b[1],T[0])),-E[2]),x(d(f(T[1],E[0]),f(-E[1],T[0])),b[2]))),p[3]),x(d(x(d(f(E[1],p[0]),f(-p[1],E[0])),T[2]),d(x(d(f(T[1],p[0]),f(-p[1],T[0])),-E[2]),x(d(f(T[1],E[0]),f(-E[1],T[0])),p[2]))),-b[3]))))),$=d(d(d(x(d(x(d(f(b[1],P[0]),f(-P[1],b[0])),p[2]),d(x(d(f(p[1],P[0]),f(-P[1],p[0])),-b[2]),x(d(f(p[1],b[0]),f(-b[1],p[0])),P[2]))),T[3]),x(d(x(d(f(b[1],P[0]),f(-P[1],b[0])),T[2]),d(x(d(f(T[1],P[0]),f(-P[1],T[0])),-b[2]),x(d(f(T[1],b[0]),f(-b[1],T[0])),P[2]))),-p[3])),d(x(d(x(d(f(p[1],P[0]),f(-P[1],p[0])),T[2]),d(x(d(f(T[1],P[0]),f(-P[1],T[0])),-p[2]),x(d(f(T[1],p[0]),f(-p[1],T[0])),P[2]))),b[3]),x(d(x(d(f(p[1],b[0]),f(-b[1],p[0])),T[2]),d(x(d(f(T[1],b[0]),f(-b[1],T[0])),-p[2]),x(d(f(T[1],p[0]),f(-p[1],T[0])),b[2]))),-P[3]))),d(d(x(d(x(d(f(p[1],P[0]),f(-P[1],p[0])),E[2]),d(x(d(f(E[1],P[0]),f(-P[1],E[0])),-p[2]),x(d(f(E[1],p[0]),f(-p[1],E[0])),P[2]))),T[3]),x(d(x(d(f(p[1],P[0]),f(-P[1],p[0])),T[2]),d(x(d(f(T[1],P[0]),f(-P[1],T[0])),-p[2]),x(d(f(T[1],p[0]),f(-p[1],T[0])),P[2]))),-E[3])),d(x(d(x(d(f(E[1],P[0]),f(-P[1],E[0])),T[2]),d(x(d(f(T[1],P[0]),f(-P[1],T[0])),-E[2]),x(d(f(T[1],E[0]),f(-E[1],T[0])),P[2]))),p[3]),x(d(x(d(f(E[1],p[0]),f(-p[1],E[0])),T[2]),d(x(d(f(T[1],p[0]),f(-p[1],T[0])),-E[2]),x(d(f(T[1],E[0]),f(-E[1],T[0])),p[2]))),-P[3])))),K=S(A,$);return K[K.length-1]}}function m(d){var f=d===3?c:d===4?l:u;return f(t,e,r,s)}var g=m(3),y=m(4),_=[function(){return 0},function(){return 0},function(d,f){return f[0]-d[0]},function(d,f,x){var S=(d[1]-x[1])*(f[0]-x[0]),T=(d[0]-x[0])*(f[1]-x[1]),E=S-T,p;if(S>0){if(T<=0)return E;p=S+T}else if(S<0){if(T>=0)return E;p=-(S+T)}else return E;var b=a*p;return E>=b||E<=-b?E:g(d,f,x)},function(d,f,x,S){var T=d[0]-S[0],E=f[0]-S[0],p=x[0]-S[0],b=d[1]-S[1],P=f[1]-S[1],A=x[1]-S[1],$=d[2]-S[2],K=f[2]-S[2],X=x[2]-S[2],B=E*A,ft=p*P,ct=p*b,mt=T*A,tt=T*P,_t=E*b,U=$*(B-ft)+K*(ct-mt)+X*(tt-_t),nt=(Math.abs(B)+Math.abs(ft))*Math.abs($)+(Math.abs(ct)+Math.abs(mt))*Math.abs(K)+(Math.abs(tt)+Math.abs(_t))*Math.abs(X),lt=h*nt;return U>lt||-U>lt?U:y(d,f,x,S)}];function I(d){var f=_[d.length];return f||(f=_[d.length]=m(d.length)),f.apply(void 0,d)}function w(d,f,x,S,T,E,p){return function(b,P,A,$,K){switch(arguments.length){case 0:case 1:return 0;case 2:return S(b,P);case 3:return T(b,P,A);case 4:return E(b,P,A,$);case 5:return p(b,P,A,$,K)}for(var X=new Array(arguments.length),B=0;B<arguments.length;++B)X[B]=arguments[B];return d(X)}}function R(){for(;_.length<=n;)_.push(m(_.length));i.exports=w.apply(void 0,[I].concat(_));for(var d=0;d<=n;++d)i.exports[d]=_[d]}R()})(co);var cu=co.exports,lu=uu,Ir=cu;function uu(i,e){for(var t=e[0],r=e[1],s=i.length,n=1,o=s,a=0,h=s-1;a<o;h=a++){var c=i[a],l=i[h],u=c[1],m=l[1];if(m<u){if(m<r&&r<u){var g=Ir(c,l,e);if(g===0)return 0;n^=0<g|0}else if(r===u){var y=i[(a+1)%s],_=y[1];if(u<_){var g=Ir(c,l,e);if(g===0)return 0;n^=0<g|0}}}else if(u<m){if(u<r&&r<m){var g=Ir(c,l,e);if(g===0)return 0;n^=g<0|0}else if(r===u){var y=i[(a+1)%s],_=y[1];if(_<u){var g=Ir(c,l,e);if(g===0)return 0;n^=g<0|0}}}else if(r===u){var I=Math.min(c[0],l[0]),w=Math.max(c[0],l[0]);if(a===0){for(;h>0;){var R=(h+s-1)%s,d=i[R];if(d[1]!==r)break;var f=d[0];I=Math.min(I,f),w=Math.max(w,f),h=R}if(h===0)return I<=t&&t<=w?0:1;o=h+1}for(var x=i[(h+s-1)%s][1];a+1<o;){var d=i[a+1];if(d[1]!==r)break;var f=d[0];I=Math.min(I,f),w=Math.max(w,f),a+=1}if(I<=t&&t<=w)return 0;var S=i[(a+1)%s][1];t<I&&x<r!=S<r&&(n^=1)}}return 2*n-1}const du=Yl(lu);var uo={};const pu="1.5.0",fu={version:pu};function po(i){return"("+i.x+";"+i.y+")"}function mu(i){var e=i.toString();return e==="[object Object]"?po(i):e}function gu(i,e){return i.y===e.y?i.x-e.x:i.y-e.y}function yu(i,e){return i.x===e.x&&i.y===e.y}var as={toString:mu,toStringBase:po,compare:gu,equals:yu},vu=as,Yr=function(i,e){this.name="PointError",this.points=e=e||[],this.message=i||"Invalid Points!";for(var t=0;t<e.length;t++)this.message+=" "+vu.toString(e[t])};Yr.prototype=new Error;Yr.prototype.constructor=Yr;var hs=Yr,or=as,J=function(i,e){this.x=+i||0,this.y=+e||0,this._p2t_edge_list=null};J.prototype.toString=function(){return or.toStringBase(this)};J.prototype.toJSON=function(){return{x:this.x,y:this.y}};J.prototype.clone=function(){return new J(this.x,this.y)};J.prototype.set_zero=function(){return this.x=0,this.y=0,this};J.prototype.set=function(i,e){return this.x=+i||0,this.y=+e||0,this};J.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this};J.prototype.add=function(i){return this.x+=i.x,this.y+=i.y,this};J.prototype.sub=function(i){return this.x-=i.x,this.y-=i.y,this};J.prototype.mul=function(i){return this.x*=i,this.y*=i,this};J.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};J.prototype.normalize=function(){var i=this.length();return this.x/=i,this.y/=i,i};J.prototype.equals=function(i){return this.x===i.x&&this.y===i.y};J.negate=function(i){return new J(-i.x,-i.y)};J.add=function(i,e){return new J(i.x+e.x,i.y+e.y)};J.sub=function(i,e){return new J(i.x-e.x,i.y-e.y)};J.mul=function(i,e){return new J(i*e.x,i*e.y)};J.cross=function(i,e){return typeof i=="number"?typeof e=="number"?i*e:new J(-i*e.y,i*e.x):typeof e=="number"?new J(e*i.y,-e*i.x):i.x*e.y-i.y*e.x};J.toString=or.toString;J.compare=or.compare;J.cmp=or.compare;J.equals=or.equals;J.dot=function(i,e){return i.x*e.x+i.y*e.y};var fo=J,wu=as,V=function(i,e,t){this.points_=[i,e,t],this.neighbors_=[null,null,null],this.interior_=!1,this.constrained_edge=[!1,!1,!1],this.delaunay_edge=[!1,!1,!1]},Ri=wu.toString;V.prototype.toString=function(){return"["+Ri(this.points_[0])+Ri(this.points_[1])+Ri(this.points_[2])+"]"};V.prototype.getPoint=function(i){return this.points_[i]};V.prototype.GetPoint=V.prototype.getPoint;V.prototype.getPoints=function(){return this.points_};V.prototype.getNeighbor=function(i){return this.neighbors_[i]};V.prototype.containsPoint=function(i){var e=this.points_;return i===e[0]||i===e[1]||i===e[2]};V.prototype.containsEdge=function(i){return this.containsPoint(i.p)&&this.containsPoint(i.q)};V.prototype.containsPoints=function(i,e){return this.containsPoint(i)&&this.containsPoint(e)};V.prototype.isInterior=function(){return this.interior_};V.prototype.setInterior=function(i){return this.interior_=i,this};V.prototype.markNeighborPointers=function(i,e,t){var r=this.points_;if(i===r[2]&&e===r[1]||i===r[1]&&e===r[2])this.neighbors_[0]=t;else if(i===r[0]&&e===r[2]||i===r[2]&&e===r[0])this.neighbors_[1]=t;else if(i===r[0]&&e===r[1]||i===r[1]&&e===r[0])this.neighbors_[2]=t;else throw new Error("poly2tri Invalid Triangle.markNeighborPointers() call")};V.prototype.markNeighbor=function(i){var e=this.points_;i.containsPoints(e[1],e[2])?(this.neighbors_[0]=i,i.markNeighborPointers(e[1],e[2],this)):i.containsPoints(e[0],e[2])?(this.neighbors_[1]=i,i.markNeighborPointers(e[0],e[2],this)):i.containsPoints(e[0],e[1])&&(this.neighbors_[2]=i,i.markNeighborPointers(e[0],e[1],this))};V.prototype.clearNeighbors=function(){this.neighbors_[0]=null,this.neighbors_[1]=null,this.neighbors_[2]=null};V.prototype.clearDelaunayEdges=function(){this.delaunay_edge[0]=!1,this.delaunay_edge[1]=!1,this.delaunay_edge[2]=!1};V.prototype.pointCW=function(i){var e=this.points_;return i===e[0]?e[2]:i===e[1]?e[0]:i===e[2]?e[1]:null};V.prototype.pointCCW=function(i){var e=this.points_;return i===e[0]?e[1]:i===e[1]?e[2]:i===e[2]?e[0]:null};V.prototype.neighborCW=function(i){return i===this.points_[0]?this.neighbors_[1]:i===this.points_[1]?this.neighbors_[2]:this.neighbors_[0]};V.prototype.neighborCCW=function(i){return i===this.points_[0]?this.neighbors_[2]:i===this.points_[1]?this.neighbors_[0]:this.neighbors_[1]};V.prototype.getConstrainedEdgeCW=function(i){return i===this.points_[0]?this.constrained_edge[1]:i===this.points_[1]?this.constrained_edge[2]:this.constrained_edge[0]};V.prototype.getConstrainedEdgeCCW=function(i){return i===this.points_[0]?this.constrained_edge[2]:i===this.points_[1]?this.constrained_edge[0]:this.constrained_edge[1]};V.prototype.getConstrainedEdgeAcross=function(i){return i===this.points_[0]?this.constrained_edge[0]:i===this.points_[1]?this.constrained_edge[1]:this.constrained_edge[2]};V.prototype.setConstrainedEdgeCW=function(i,e){i===this.points_[0]?this.constrained_edge[1]=e:i===this.points_[1]?this.constrained_edge[2]=e:this.constrained_edge[0]=e};V.prototype.setConstrainedEdgeCCW=function(i,e){i===this.points_[0]?this.constrained_edge[2]=e:i===this.points_[1]?this.constrained_edge[0]=e:this.constrained_edge[1]=e};V.prototype.getDelaunayEdgeCW=function(i){return i===this.points_[0]?this.delaunay_edge[1]:i===this.points_[1]?this.delaunay_edge[2]:this.delaunay_edge[0]};V.prototype.getDelaunayEdgeCCW=function(i){return i===this.points_[0]?this.delaunay_edge[2]:i===this.points_[1]?this.delaunay_edge[0]:this.delaunay_edge[1]};V.prototype.setDelaunayEdgeCW=function(i,e){i===this.points_[0]?this.delaunay_edge[1]=e:i===this.points_[1]?this.delaunay_edge[2]=e:this.delaunay_edge[0]=e};V.prototype.setDelaunayEdgeCCW=function(i,e){i===this.points_[0]?this.delaunay_edge[2]=e:i===this.points_[1]?this.delaunay_edge[0]=e:this.delaunay_edge[1]=e};V.prototype.neighborAcross=function(i){return i===this.points_[0]?this.neighbors_[0]:i===this.points_[1]?this.neighbors_[1]:this.neighbors_[2]};V.prototype.oppositePoint=function(i,e){var t=i.pointCW(e);return this.pointCW(t)};V.prototype.legalize=function(i,e){var t=this.points_;if(i===t[0])t[1]=t[0],t[0]=t[2],t[2]=e;else if(i===t[1])t[2]=t[1],t[1]=t[0],t[0]=e;else if(i===t[2])t[0]=t[2],t[2]=t[1],t[1]=e;else throw new Error("poly2tri Invalid Triangle.legalize() call")};V.prototype.index=function(i){var e=this.points_;if(i===e[0])return 0;if(i===e[1])return 1;if(i===e[2])return 2;throw new Error("poly2tri Invalid Triangle.index() call")};V.prototype.edgeIndex=function(i,e){var t=this.points_;if(i===t[0]){if(e===t[1])return 2;if(e===t[2])return 1}else if(i===t[1]){if(e===t[2])return 0;if(e===t[0])return 2}else if(i===t[2]){if(e===t[0])return 1;if(e===t[1])return 0}return-1};V.prototype.markConstrainedEdgeByIndex=function(i){this.constrained_edge[i]=!0};V.prototype.markConstrainedEdgeByEdge=function(i){this.markConstrainedEdgeByPoints(i.p,i.q)};V.prototype.markConstrainedEdgeByPoints=function(i,e){var t=this.points_;e===t[0]&&i===t[1]||e===t[1]&&i===t[0]?this.constrained_edge[2]=!0:e===t[0]&&i===t[2]||e===t[2]&&i===t[0]?this.constrained_edge[1]=!0:(e===t[1]&&i===t[2]||e===t[2]&&i===t[1])&&(this.constrained_edge[0]=!0)};var cs=V,ls={};function xu(i,e){if(!i)throw new Error(e||"Assert Failed")}var bu=xu,us={exports:{}},Mu=function(i,e){this.point=i,this.triangle=e||null,this.next=null,this.prev=null,this.value=i.x},Ft=function(i,e){this.head_=i,this.tail_=e,this.search_node_=i};Ft.prototype.head=function(){return this.head_};Ft.prototype.setHead=function(i){this.head_=i};Ft.prototype.tail=function(){return this.tail_};Ft.prototype.setTail=function(i){this.tail_=i};Ft.prototype.search=function(){return this.search_node_};Ft.prototype.setSearch=function(i){this.search_node_=i};Ft.prototype.findSearchNode=function(){return this.search_node_};Ft.prototype.locateNode=function(i){var e=this.search_node_;if(i<e.value){for(;e=e.prev;)if(i>=e.value)return this.search_node_=e,e}else for(;e=e.next;)if(i<e.value)return this.search_node_=e.prev,e.prev;return null};Ft.prototype.locatePoint=function(i){var e=i.x,t=this.findSearchNode(e),r=t.point.x;if(e===r){if(i!==t.point)if(i===t.prev.point)t=t.prev;else if(i===t.next.point)t=t.next;else throw new Error("poly2tri Invalid AdvancingFront.locatePoint() call")}else if(e<r)for(;(t=t.prev)&&i!==t.point;);else for(;(t=t.next)&&i!==t.point;);return t&&(this.search_node_=t),t};us.exports=Ft;us.exports.Node=Mu;var mo=us.exports,Se={},rr=1e-12;Se.EPSILON=rr;var jr={CW:1,CCW:-1,COLLINEAR:0};Se.Orientation=jr;function Eu(i,e,t){var r=(i.x-t.x)*(e.y-t.y),s=(i.y-t.y)*(e.x-t.x),n=r-s;return n>-rr&&n<rr?jr.COLLINEAR:n>0?jr.CCW:jr.CW}Se.orient2d=Eu;function _u(i,e,t,r){var s=(i.x-e.x)*(r.y-e.y)-(r.x-e.x)*(i.y-e.y);if(s>=-rr)return!1;var n=(i.x-t.x)*(r.y-t.y)-(r.x-t.x)*(i.y-t.y);return!(n<=rr)}Se.inScanArea=_u;function Tu(i,e,t){var r=e.x-i.x,s=e.y-i.y,n=t.x-i.x,o=t.y-i.y;return r*n+s*o<0}Se.isAngleObtuse=Tu;var ds=bu,Kr=hs,go=cs,Pu=mo.Node,ar=Se,Iu=ar.EPSILON,it=ar.Orientation,ht=ar.orient2d,yo=ar.inScanArea,Hs=ar.isAngleObtuse;function Ru(i){i.initTriangulation(),i.createAdvancingFront(),Su(i),Au(i)}function Su(i){var e,t=i.pointCount();for(e=1;e<t;++e)for(var r=i.getPoint(e),s=Cu(i,r),n=r._p2t_edge_list,o=0;n&&o<n.length;++o)ku(i,n[o],s)}function Au(i){for(var e=i.front().head().next.triangle,t=i.front().head().next.point;!e.getConstrainedEdgeCW(t);)e=e.neighborCCW(t);i.meshClean(e)}function Cu(i,e){var t=i.locateNode(e),r=ju(i,e,t);return e.x<=t.point.x+Iu&&Pe(i,t),Lu(i,r),r}function ku(i,e,t){i.edge_event.constrained_edge=e,i.edge_event.right=e.p.x>e.q.x,!vo(t.triangle,e.p,e.q)&&(Gu(i,e,t),ps(i,e.p,e.q,t.triangle,e.q))}function ps(i,e,t,r,s){if(!vo(r,e,t)){var n=r.pointCCW(s),o=ht(t,n,e);if(o===it.COLLINEAR)throw new Kr("poly2tri EdgeEvent: Collinear not supported!",[t,n,e]);var a=r.pointCW(s),h=ht(t,a,e);if(h===it.COLLINEAR)throw new Kr("poly2tri EdgeEvent: Collinear not supported!",[t,a,e]);o===h?(o===it.CW?r=r.neighborCCW(s):r=r.neighborCW(s),ps(i,e,t,r,s)):gs(i,e,t,r,s)}}function vo(i,e,t){var r=i.edgeIndex(e,t);if(r!==-1){i.markConstrainedEdgeByIndex(r);var s=i.getNeighbor(r);return s&&s.markConstrainedEdgeByPoints(e,t),!0}return!1}function ju(i,e,t){var r=new go(e,t.point,t.next.point);r.markNeighbor(t.triangle),i.addToMap(r);var s=new Pu(e);return s.next=t.next,s.prev=t,t.next.prev=s,t.next=s,ie(i,r)||i.mapTriangleToNodes(r),s}function Pe(i,e){var t=new go(e.prev.point,e.point,e.next.point);t.markNeighbor(e.prev.triangle),t.markNeighbor(e.triangle),i.addToMap(t),e.prev.next=e.next,e.next.prev=e.prev,ie(i,t)||i.mapTriangleToNodes(t)}function Lu(i,e){for(var t=e.next;t.next&&!Hs(t.point,t.next.point,t.prev.point);)Pe(i,t),t=t.next;for(t=e.prev;t.prev&&!Hs(t.point,t.next.point,t.prev.point);)Pe(i,t),t=t.prev;e.next&&e.next.next&&Ou(e)&&Nu(i,e)}function Ou(i){var e=i.point.x-i.next.next.point.x,t=i.point.y-i.next.next.point.y;return ds(t>=0,"unordered y"),e>=0||Math.abs(e)<t}function ie(i,e){for(var t=0;t<3;++t)if(!e.delaunay_edge[t]){var r=e.getNeighbor(t);if(r){var s=e.getPoint(t),n=r.oppositePoint(e,s),o=r.index(n);if(r.constrained_edge[o]||r.delaunay_edge[o]){e.constrained_edge[t]=r.constrained_edge[o];continue}var a=Du(s,e.pointCCW(s),e.pointCW(s),n);if(a){e.delaunay_edge[t]=!0,r.delaunay_edge[o]=!0,wo(e,s,r,n);var h=!ie(i,e);return h&&i.mapTriangleToNodes(e),h=!ie(i,r),h&&i.mapTriangleToNodes(r),e.delaunay_edge[t]=!1,r.delaunay_edge[o]=!1,!0}}}return!1}function Du(i,e,t,r){var s=i.x-r.x,n=i.y-r.y,o=e.x-r.x,a=e.y-r.y,h=s*a,c=o*n,l=h-c;if(l<=0)return!1;var u=t.x-r.x,m=t.y-r.y,g=u*n,y=s*m,_=g-y;if(_<=0)return!1;var I=o*m,w=u*a,R=s*s+n*n,d=o*o+a*a,f=u*u+m*m,x=R*(I-w)+d*_+f*l;return x>0}function wo(i,e,t,r){var s,n,o,a;s=i.neighborCCW(e),n=i.neighborCW(e),o=t.neighborCCW(r),a=t.neighborCW(r);var h,c,l,u;h=i.getConstrainedEdgeCCW(e),c=i.getConstrainedEdgeCW(e),l=t.getConstrainedEdgeCCW(r),u=t.getConstrainedEdgeCW(r);var m,g,y,_;m=i.getDelaunayEdgeCCW(e),g=i.getDelaunayEdgeCW(e),y=t.getDelaunayEdgeCCW(r),_=t.getDelaunayEdgeCW(r),i.legalize(e,r),t.legalize(r,e),t.setDelaunayEdgeCCW(e,m),i.setDelaunayEdgeCW(e,g),i.setDelaunayEdgeCCW(r,y),t.setDelaunayEdgeCW(r,_),t.setConstrainedEdgeCCW(e,h),i.setConstrainedEdgeCW(e,c),i.setConstrainedEdgeCCW(r,l),t.setConstrainedEdgeCW(r,u),i.clearNeighbors(),t.clearNeighbors(),s&&t.markNeighbor(s),n&&i.markNeighbor(n),o&&i.markNeighbor(o),a&&t.markNeighbor(a),i.markNeighbor(t)}function Nu(i,e){for(ht(e.point,e.next.point,e.next.next.point)===it.CCW?i.basin.left_node=e.next.next:i.basin.left_node=e.next,i.basin.bottom_node=i.basin.left_node;i.basin.bottom_node.next&&i.basin.bottom_node.point.y>=i.basin.bottom_node.next.point.y;)i.basin.bottom_node=i.basin.bottom_node.next;if(i.basin.bottom_node!==i.basin.left_node){for(i.basin.right_node=i.basin.bottom_node;i.basin.right_node.next&&i.basin.right_node.point.y<i.basin.right_node.next.point.y;)i.basin.right_node=i.basin.right_node.next;i.basin.right_node!==i.basin.bottom_node&&(i.basin.width=i.basin.right_node.point.x-i.basin.left_node.point.x,i.basin.left_highest=i.basin.left_node.point.y>i.basin.right_node.point.y,xo(i,i.basin.bottom_node))}}function xo(i,e){if(!Fu(i,e)){Pe(i,e);var t;if(!(e.prev===i.basin.left_node&&e.next===i.basin.right_node)){if(e.prev===i.basin.left_node){if(t=ht(e.point,e.next.point,e.next.next.point),t===it.CW)return;e=e.next}else if(e.next===i.basin.right_node){if(t=ht(e.point,e.prev.point,e.prev.prev.point),t===it.CCW)return;e=e.prev}else e.prev.point.y<e.next.point.y?e=e.prev:e=e.next;xo(i,e)}}}function Fu(i,e){var t;return i.basin.left_highest?t=i.basin.left_node.point.y-e.point.y:t=i.basin.right_node.point.y-e.point.y,i.basin.width>t}function Gu(i,e,t){i.edge_event.right?Bu(i,e,t):Uu(i,e,t)}function Bu(i,e,t){for(;t.next.point.x<e.p.x;)ht(e.q,t.next.point,e.p)===it.CCW?bo(i,e,t):t=t.next}function bo(i,e,t){t.point.x<e.p.x&&(ht(t.point,t.next.point,t.next.next.point)===it.CCW?fs(i,e,t):(Mo(i,e,t),bo(i,e,t)))}function fs(i,e,t){Pe(i,t.next),t.next.point!==e.p&&ht(e.q,t.next.point,e.p)===it.CCW&&ht(t.point,t.next.point,t.next.next.point)===it.CCW&&fs(i,e,t)}function Mo(i,e,t){ht(t.next.point,t.next.next.point,t.next.next.next.point)===it.CCW?fs(i,e,t.next):ht(e.q,t.next.next.point,e.p)===it.CCW&&Mo(i,e,t.next)}function Uu(i,e,t){for(;t.prev.point.x>e.p.x;)ht(e.q,t.prev.point,e.p)===it.CW?Eo(i,e,t):t=t.prev}function Eo(i,e,t){t.point.x>e.p.x&&(ht(t.point,t.prev.point,t.prev.prev.point)===it.CW?ms(i,e,t):(_o(i,e,t),Eo(i,e,t)))}function _o(i,e,t){ht(t.prev.point,t.prev.prev.point,t.prev.prev.prev.point)===it.CW?ms(i,e,t.prev):ht(e.q,t.prev.prev.point,e.p)===it.CW&&_o(i,e,t.prev)}function ms(i,e,t){Pe(i,t.prev),t.prev.point!==e.p&&ht(e.q,t.prev.point,e.p)===it.CW&&ht(t.point,t.prev.point,t.prev.prev.point)===it.CW&&ms(i,e,t)}function gs(i,e,t,r,s){var n=r.neighborAcross(s);ds(n,"FLIP failed due to missing triangle!");var o=n.oppositePoint(r,s);if(r.getConstrainedEdgeAcross(s)){var a=r.index(s);throw new Kr("poly2tri Intersecting Constraints",[s,o,r.getPoint((a+1)%3),r.getPoint((a+2)%3)])}if(yo(s,r.pointCCW(s),r.pointCW(s),o))if(wo(r,s,n,o),i.mapTriangleToNodes(r),i.mapTriangleToNodes(n),s===t&&o===e)t===i.edge_event.constrained_edge.q&&e===i.edge_event.constrained_edge.p&&(r.markConstrainedEdgeByPoints(e,t),n.markConstrainedEdgeByPoints(e,t),ie(i,r),ie(i,n));else{var h=ht(t,o,e);r=zu(i,h,r,n,s,o),gs(i,e,t,r,s)}else{var c=To(e,t,n,o);Po(i,e,t,r,n,c),ps(i,e,t,r,s)}}function zu(i,e,t,r,s,n){var o;return e===it.CCW?(o=r.edgeIndex(s,n),r.delaunay_edge[o]=!0,ie(i,r),r.clearDelaunayEdges(),t):(o=t.edgeIndex(s,n),t.delaunay_edge[o]=!0,ie(i,t),t.clearDelaunayEdges(),r)}function To(i,e,t,r){var s=ht(e,r,i);if(s===it.CW)return t.pointCCW(r);if(s===it.CCW)return t.pointCW(r);throw new Kr("poly2tri [Unsupported] nextFlipPoint: opposing point on constrained edge!",[e,r,i])}function Po(i,e,t,r,s,n){var o=s.neighborAcross(n);ds(o,"FLIP failed due to missing triangle");var a=o.oppositePoint(s,n);if(yo(t,r.pointCCW(t),r.pointCW(t),a))gs(i,t,a,o,a);else{var h=To(e,t,o,a);Po(i,e,t,r,o,h)}}ls.triangulate=Ru;var Wu=hs,Ce=fo,Zu=cs,Vu=ls,Io=mo,Si=Io.Node,Ys=.3,qu=function(i,e){if(this.p=i,this.q=e,i.y>e.y)this.q=i,this.p=e;else if(i.y===e.y){if(i.x>e.x)this.q=i,this.p=e;else if(i.x===e.x)throw new Wu("poly2tri Invalid Edge constructor: repeated points!",[i])}this.q._p2t_edge_list||(this.q._p2t_edge_list=[]),this.q._p2t_edge_list.push(this)},Ro=function(){this.left_node=null,this.bottom_node=null,this.right_node=null,this.width=0,this.left_highest=!1};Ro.prototype.clear=function(){this.left_node=null,this.bottom_node=null,this.right_node=null,this.width=0,this.left_highest=!1};var $u=function(){this.constrained_edge=null,this.right=!1},Y=function(i,e){e=e||{},this.triangles_=[],this.map_=[],this.points_=e.cloneArrays?i.slice(0):i,this.edge_list=[],this.pmin_=this.pmax_=null,this.front_=null,this.head_=null,this.tail_=null,this.af_head_=null,this.af_middle_=null,this.af_tail_=null,this.basin=new Ro,this.edge_event=new $u,this.initEdges(this.points_)};Y.prototype.addHole=function(i){this.initEdges(i);var e,t=i.length;for(e=0;e<t;e++)this.points_.push(i[e]);return this};Y.prototype.AddHole=Y.prototype.addHole;Y.prototype.addHoles=function(i){var e,t=i.length;for(e=0;e<t;e++)this.initEdges(i[e]);return this.points_=this.points_.concat.apply(this.points_,i),this};Y.prototype.addPoint=function(i){return this.points_.push(i),this};Y.prototype.AddPoint=Y.prototype.addPoint;Y.prototype.addPoints=function(i){return this.points_=this.points_.concat(i),this};Y.prototype.triangulate=function(){return Vu.triangulate(this),this};Y.prototype.getBoundingBox=function(){return{min:this.pmin_,max:this.pmax_}};Y.prototype.getTriangles=function(){return this.triangles_};Y.prototype.GetTriangles=Y.prototype.getTriangles;Y.prototype.front=function(){return this.front_};Y.prototype.pointCount=function(){return this.points_.length};Y.prototype.head=function(){return this.head_};Y.prototype.setHead=function(i){this.head_=i};Y.prototype.tail=function(){return this.tail_};Y.prototype.setTail=function(i){this.tail_=i};Y.prototype.getMap=function(){return this.map_};Y.prototype.initTriangulation=function(){var i=this.points_[0].x,e=this.points_[0].x,t=this.points_[0].y,r=this.points_[0].y,s,n=this.points_.length;for(s=1;s<n;s++){var o=this.points_[s];o.x>i&&(i=o.x),o.x<e&&(e=o.x),o.y>t&&(t=o.y),o.y<r&&(r=o.y)}this.pmin_=new Ce(e,r),this.pmax_=new Ce(i,t);var a=Ys*(i-e),h=Ys*(t-r);this.head_=new Ce(i+a,r-h),this.tail_=new Ce(e-a,r-h),this.points_.sort(Ce.compare)};Y.prototype.initEdges=function(i){var e,t=i.length;for(e=0;e<t;++e)this.edge_list.push(new qu(i[e],i[(e+1)%t]))};Y.prototype.getPoint=function(i){return this.points_[i]};Y.prototype.addToMap=function(i){this.map_.push(i)};Y.prototype.locateNode=function(i){return this.front_.locateNode(i.x)};Y.prototype.createAdvancingFront=function(){var i,e,t,r=new Zu(this.points_[0],this.tail_,this.head_);this.map_.push(r),i=new Si(r.getPoint(1),r),e=new Si(r.getPoint(0),r),t=new Si(r.getPoint(2)),this.front_=new Io(i,t),i.next=e,e.next=t,e.prev=i,t.prev=e};Y.prototype.removeNode=function(i){};Y.prototype.mapTriangleToNodes=function(i){for(var e=0;e<3;++e)if(!i.getNeighbor(e)){var t=this.front_.locatePoint(i.pointCW(i.getPoint(e)));t&&(t.triangle=i)}};Y.prototype.removeFromMap=function(i){var e,t=this.map_,r=t.length;for(e=0;e<r;e++)if(t[e]===i){t.splice(e,1);break}};Y.prototype.meshClean=function(i){for(var e=[i],t,r;t=e.pop();)if(!t.isInterior())for(t.setInterior(!0),this.triangles_.push(t),r=0;r<3;r++)t.constrained_edge[r]||e.push(t.getNeighbor(r))};var Xu=Y;(function(i){var e=globalThis.poly2tri;i.noConflict=function(){return globalThis.poly2tri=e,i},i.VERSION=fu.version,i.PointError=hs,i.Point=fo,i.Triangle=cs,i.SweepContext=Xu;var t=ls;i.triangulate=t.triangulate,i.sweep={Triangulate:t.triangulate}})(uo);function Hu(i,e){let t=0;const r=new uo.SweepContext(Xl(i,e).map(s=>({x:s[0],y:s[1],type:"p",item:t++})));r.addPoints(Hl(i,e).filter(s=>du(i,s)===-1).map(s=>({x:s[0],y:s[1],type:"g",item:t++})));try{r.triangulate()}catch{throw new Error("A Point Error occured during resource mask triangulation. This is typically because the resource mask contains duplicate or collinear points, or is self-intersecting.")}return r.getTriangles()}function Yu(i,e){const t=Hu(i,e).map(s=>s.getPoints().map(n=>n)),r=[...new Map(t.flat().map(s=>[s.item,s])).values()].sort((s,n)=>s.item-n.item).map(s=>[s.x,s.y]);return{uniquePointsIndexTriangles:t.map(s=>s.map(n=>n.item)),uniquePoints:r}}const Ku=80,Ju=10;function Qu(){return{}}class td extends Wl{constructor(t,r,s){s={...Qu(),...s};super(t,r,s);M(this,"resourceTrianglePoints",[]);M(this,"resourceUniquePoints",[]);M(this,"trianglePointsUniquePointsIndex",[]);M(this,"triangulationByBestScaleFactor",new Map);M(this,"triangulateErrorCount",0);M(this,"projectedGeoPreviousTrianglePoints",[]);M(this,"projectedGeoTrianglePoints",[]);M(this,"projectedGeoUniquePoints",[]);M(this,"projectedGeoUniquePointsByBestScaleFactorAndTransformationType",new Map);M(this,"projectedGeoUniquePointsPartialDerivativeX",[]);M(this,"projectedGeoUniquePointsPartialDerivativeY",[]);M(this,"projectedGeoUniquePointsPartialDerivativeXByBestScaleFactorAndTransformationType",new Map);M(this,"projectedGeoUniquePointsPartialDerivativeYByBestScaleFactorAndTransformationType",new Map);M(this,"previousTrianglePointsDistortion",[]);M(this,"trianglePointsDistortion",[]);M(this,"uniquePointsDistortion",[])}setResourceMask(t){super.setResourceMask(t),this.triangulationByBestScaleFactor=new Map,this.projectedGeoUniquePointsByBestScaleFactorAndTransformationType=new Map,this.projectedGeoUniquePointsPartialDerivativeXByBestScaleFactorAndTransformationType=new Map,this.projectedGeoUniquePointsPartialDerivativeYByBestScaleFactorAndTransformationType=new Map,this.updateTriangulation()}setBestScaleFactor(t){const r=super.setBestScaleFactor(t);return r&&this.updateTriangulation(!0),r}updateTriangulation(t=!1){const{trianglePointsUniquePointsIndex:r,resourceUniquePoints:s}=Ar(this.triangulationByBestScaleFactor,this.bestScaleFactor,()=>{var o;const n=Aa(this.resourceMask)*this.bestScaleFactor/Ku;try{const{uniquePointsIndexTriangles:a,uniquePoints:h}=Yu(this.resourceMask,n);return{trianglePointsUniquePointsIndex:a.flat(),resourceUniquePoints:h}}catch(a){return this.triangulateErrorCount++,this.triangulateErrorCount<=Ju&&(console.error(`Error computing triangulation for map ${this.mapId}.`,`Fix this map with Allmaps Editor: https://editor.allmaps.org/#/collection?url=${(o=this.parsedImage)==null?void 0:o.uri}/info.json`),this.triangulateErrorCount===1&&console.error(a)),{trianglePointsUniquePointsIndex:this.trianglePointsUniquePointsIndex,resourceUniquePoints:this.resourceUniquePoints}}});this.resourceTrianglePoints=r.map(n=>s[n]),this.resourceUniquePoints=s,this.trianglePointsUniquePointsIndex=r,this.updateProjectedGeoTrianglePoints(t)}updateProjectedGeoTrianglePoints(t=!1){this.projectedGeoUniquePoints=Mi(this.projectedGeoUniquePointsByBestScaleFactorAndTransformationType,this.bestScaleFactor,this.transformationType,()=>this.resourceUniquePoints.map(r=>this.projectedTransformer.transformToGeo(r))),this.projectedGeoTrianglePoints=this.trianglePointsUniquePointsIndex.map(r=>this.projectedGeoUniquePoints[r]),(t||!this.projectedGeoPreviousTrianglePoints.length)&&(this.projectedGeoPreviousTrianglePoints=this.projectedGeoTrianglePoints),this.updateTrianglePointsDistortion(t)}updateTrianglePointsDistortion(t=!1){this.distortionMeasure&&(this.projectedGeoUniquePointsPartialDerivativeX=Mi(this.projectedGeoUniquePointsPartialDerivativeXByBestScaleFactorAndTransformationType,this.bestScaleFactor,this.transformationType,()=>this.resourceUniquePoints.map(r=>this.projectedTransformer.transformToGeo(r,{evaluationType:"partialDerivativeX"}))),this.projectedGeoUniquePointsPartialDerivativeY=Mi(this.projectedGeoUniquePointsPartialDerivativeYByBestScaleFactorAndTransformationType,this.bestScaleFactor,this.transformationType,()=>this.resourceUniquePoints.map(r=>this.projectedTransformer.transformToGeo(r,{evaluationType:"partialDerivativeY"})))),this.uniquePointsDistortion=this.projectedGeoUniquePoints.map((r,s)=>Ul(this.projectedGeoUniquePointsPartialDerivativeX[s],this.projectedGeoUniquePointsPartialDerivativeY[s],this.distortionMeasure,this.getReferenceScale())),this.trianglePointsDistortion=this.trianglePointsUniquePointsIndex.map(r=>this.uniquePointsDistortion[r]),(t||!this.previousTrianglePointsDistortion.length)&&(this.previousTrianglePointsDistortion=this.trianglePointsDistortion)}resetTrianglePoints(){this.projectedGeoPreviousTrianglePoints=this.projectedGeoTrianglePoints,this.previousTrianglePointsDistortion=this.trianglePointsDistortion}mixTrianglePoints(t){this.projectedGeoPreviousTrianglePoints=this.projectedGeoTrianglePoints.map((r,s)=>ya(r,this.projectedGeoPreviousTrianglePoints[s],t)),this.previousTrianglePointsDistortion=this.trianglePointsDistortion.map((r,s)=>ga(r,this.previousTrianglePointsDistortion[s],t))}}function ed(i){let e=0,t=0;for(const o of i)e+=o.w*o.h,t=Math.max(t,o.w);i.sort((o,a)=>a.h-o.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),t),h:1/0}];let s=0,n=0;for(const o of i)for(let a=r.length-1;a>=0;a--){const h=r[a];if(!(o.w>h.w||o.h>h.h)){if(o.x=h.x,o.y=h.y,n=Math.max(n,o.y+o.h),s=Math.max(s,o.x+o.w),o.w===h.w&&o.h===h.h){const c=r.pop();a<r.length&&(r[a]=c)}else o.h===h.h?(h.x+=o.w,h.w-=o.w):o.w===h.w?(h.y+=o.h,h.h-=o.h):(r.push({x:h.x+o.w,y:h.y,w:h.w-o.w,h:o.h}),h.y+=o.h,h.h-=o.h);break}}return{w:s,h:n,fill:e/(s*n)||0}}var rd=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,id=typeof self=="object"&&self&&self.Object===Object&&self,So=rd||id||Function("return this")(),Jr=So.Symbol,Ao=Object.prototype,sd=Ao.hasOwnProperty,nd=Ao.toString,ke=Jr?Jr.toStringTag:void 0;function od(i){var e=sd.call(i,ke),t=i[ke];try{i[ke]=void 0;var r=!0}catch{}var s=nd.call(i);return r&&(e?i[ke]=t:delete i[ke]),s}var ad=Object.prototype,hd=ad.toString;function cd(i){return hd.call(i)}var ld="[object Null]",ud="[object Undefined]",Ks=Jr?Jr.toStringTag:void 0;function dd(i){return i==null?i===void 0?ud:ld:Ks&&Ks in Object(i)?od(i):cd(i)}function pd(i){return i!=null&&typeof i=="object"}var fd="[object Symbol]";function md(i){return typeof i=="symbol"||pd(i)&&dd(i)==fd}var gd=/\s/;function yd(i){for(var e=i.length;e--&&gd.test(i.charAt(e)););return e}var vd=/^\s+/;function wd(i){return i&&i.slice(0,yd(i)+1).replace(vd,"")}function Qr(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var Js=NaN,xd=/^[-+]0x[0-9a-f]+$/i,bd=/^0b[01]+$/i,Md=/^0o[0-7]+$/i,Ed=parseInt;function Qs(i){if(typeof i=="number")return i;if(md(i))return Js;if(Qr(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=Qr(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=wd(i);var t=bd.test(i);return t||Md.test(i)?Ed(i.slice(2),t?2:8):xd.test(i)?Js:+i}var Ai=function(){return So.Date.now()},_d="Expected a function",Td=Math.max,Pd=Math.min;function Id(i,e,t){var r,s,n,o,a,h,c=0,l=!1,u=!1,m=!0;if(typeof i!="function")throw new TypeError(_d);e=Qs(e)||0,Qr(t)&&(l=!!t.leading,u="maxWait"in t,n=u?Td(Qs(t.maxWait)||0,e):n,m="trailing"in t?!!t.trailing:m);function g(S){var T=r,E=s;return r=s=void 0,c=S,o=i.apply(E,T),o}function y(S){return c=S,a=setTimeout(w,e),l?g(S):o}function _(S){var T=S-h,E=S-c,p=e-T;return u?Pd(p,n-E):p}function I(S){var T=S-h,E=S-c;return h===void 0||T>=e||T<0||u&&E>=n}function w(){var S=Ai();if(I(S))return R(S);a=setTimeout(w,_(S))}function R(S){return a=void 0,m&&r?g(S):(r=s=void 0,o)}function d(){a!==void 0&&clearTimeout(a),c=0,r=h=s=a=void 0}function f(){return a===void 0?o:R(Ai())}function x(){var S=Ai(),T=I(S);if(r=arguments,s=this,h=S,T){if(a===void 0)return y(h);if(u)return clearTimeout(a),a=setTimeout(w,e),g(h)}return a===void 0&&(a=setTimeout(w,e)),o}return x.cancel=d,x.flush=f,x}var Rd="Expected a function";function Hi(i,e,t){var r=!0,s=!0;if(typeof i!="function")throw new TypeError(Rd);return Qr(t)&&(r="leading"in t?!!t.leading:r,s="trailing"in t?!!t.trailing:s),Id(i,e,{leading:r,maxWait:e,trailing:s})}const Sd=.5;function Co(i,e){return`${i}:${e}`}function ko(i){return Co(i.mapId,i.tileUrl)}function Ci(i){return new Set(i.map(e=>ko(e)))}function Ad(i,e,t=Sd){let r=Number.POSITIVE_INFINITY,s=i.tileZoomLevels.at(-1);for(const n of i.tileZoomLevels){const o=Math.abs(Math.log(n.scaleFactor)-Math.log(e+t));o<r&&(r=o,s=n)}return s}function Cd(i,e,t){const r=kd(i,e),s=jd(r),n=Od(s,t,e),o=be(dt(i));return n.sort((a,h)=>tn(a,o)-tn(h,o)),n}function kd(i,e){return i.map(t=>[t[0]/e.originalWidth,t[1]/e.originalHeight])}function jd(i){const e={};for(let t=0;t<i.length;t++){const r=[i[t],i[(t+1)%i.length]];Ld(r).forEach(([s,n])=>{e[s]||(e[s]=[Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY]),n<e[s][0]&&(e[s][0]=n),n>e[s][1]&&(e[s][1]=n)})}return e}function Ld([i,e]){let t=Math.floor(i[0]),r=Math.floor(i[1]);const s=Math.floor(e[0]),n=Math.floor(e[1]),o=[[t,r]];if(t===s&&r===n)return o;const a=Math.sign(e[0]-i[0]),h=Math.sign(e[1]-i[1]),c=Math.abs(i[0]-t-Math.max(0,a)),l=Math.abs(i[1]-r-Math.max(0,h)),u=Math.abs(i[0]-e[0]),m=Math.abs(i[1]-e[1]);let g=c/u,y=l/m;const _=1/u,I=1/m;for(;!(t===s&&r===n);)g<y?(g=g+_,t=t+a):(y=y+I,r=r+h),o.push([t,r]);return o}function Od(i,e,t){const r=[];for(const s in i){const n=parseInt(s);if(n<0||n>=t.columns)break;const o=Math.max(i[n][0],0),a=Math.min(i[n][1],t.rows-1);for(let h=o;h<=a;h++)r.push({column:n,row:h,tileZoomLevel:t,imageSize:[e.width,e.height]})}return r}function Dd(i){var e,t;return(((e=i.imageRequest.size)==null?void 0:e.height)||0)*(((t=i.imageRequest.size)==null?void 0:t.width)||0)*3}function tn(i,e){return bt(Nd(i),e)}function Nd(i){const e=jo(i);return[(e[2]-e[0])/2+e[0],(e[3]-e[1])/2+e[1]]}function Fd(i){const e=i.column*i.tileZoomLevel.originalWidth,t=i.row*i.tileZoomLevel.originalHeight;return[e,t]}function jo(i){const e=Fd(i),t=Math.min(e[0]+i.tileZoomLevel.originalWidth,i.imageSize[0]),r=Math.min(e[1]+i.tileZoomLevel.originalHeight,i.imageSize[1]);return[e[0],e[1],t,r]}function en(i,e,t){const r=i.createShader(e);if(r){if(i.shaderSource(r,t),i.compileShader(r),i.getShaderParameter(r,i.COMPILE_STATUS))return r;{const s=i.getShaderInfoLog(r);throw i.deleteShader(r),new Error("Failed to compile shader: "+s)}}else throw new Error("Failed to create shader")}function Gd(i,e,t){const r=i.createProgram();if(r){if(i.attachShader(r,e),i.attachShader(r,t),i.linkProgram(r),i.getProgramParameter(r,i.LINK_STATUS))return r;{const s=i.getProgramInfoLog(r);throw i.deleteProgram(r),new Error("Failed to link program: "+s)}}else throw new Error("Failed to create program")}function de(i,e,t,r,s){const n=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,n),i.bufferData(i.ARRAY_BUFFER,t,i.STATIC_DRAW);const o=i.FLOAT,a=!1,h=0,c=0,l=i.getAttribLocation(e,s);i.vertexAttribPointer(l,r,o,a,h,c),i.enableVertexAttribArray(l)}const Bd=100,Ud={leading:!0,trailing:!0},zd=1,Wd=1;function Zd(i,e){return(t,r,s)=>new Vd(t,r,i,e,s)}let Vd=class extends td{constructor(e,t,r,s,n){super(e,t,n);M(this,"gl");M(this,"program");M(this,"vao");M(this,"CachedTilesByTileUrl",new Map);M(this,"opacity",zd);M(this,"saturation",Wd);M(this,"renderOptions",{});M(this,"packedTilesTexture");M(this,"packedTilesPositionsTexture");M(this,"packedTilesResourcePositionsAndDimensionsTexture");M(this,"packedTilesScaleFactorsTexture");M(this,"projectedGeoToClipTransform");M(this,"throttledUpdateTextures");this.gl=r,this.program=s,this.vao=r.createVertexArray(),this.packedTilesTexture=r.createTexture(),this.packedTilesScaleFactorsTexture=r.createTexture(),this.packedTilesPositionsTexture=r.createTexture(),this.packedTilesResourcePositionsAndDimensionsTexture=r.createTexture(),this.throttledUpdateTextures=Hi(this.updateTextures.bind(this),Bd,Ud)}updateVertexBuffers(e){this.projectedGeoToClipTransform=e,this.updateVertexBuffersInternal()}addCachedTileAndUpdateTextures(e){this.CachedTilesByTileUrl.set(e.tileUrl,e),this.throttledUpdateTextures()}removeCachedTileAndUpdateTextures(e){this.CachedTilesByTileUrl.delete(e),this.throttledUpdateTextures()}dispose(){this.gl.deleteVertexArray(this.vao),this.gl.deleteTexture(this.packedTilesTexture),this.gl.deleteTexture(this.packedTilesScaleFactorsTexture),this.gl.deleteTexture(this.packedTilesPositionsTexture),this.gl.deleteTexture(this.packedTilesResourcePositionsAndDimensionsTexture)}updateVertexBuffersInternal(){if(!this.vao||!this.projectedGeoToClipTransform)return;this.gl.bindVertexArray(this.vao);const e=this.resourceTrianglePoints;de(this.gl,this.program,new Float32Array(e.flat()),2,"a_resourceTrianglePoint");const t=this.projectedGeoPreviousTrianglePoints.map(a=>we(this.projectedGeoToClipTransform,a));de(this.gl,this.program,new Float32Array(t.flat()),2,"a_clipPreviousTrianglePoint");const r=this.projectedGeoTrianglePoints.map(a=>we(this.projectedGeoToClipTransform,a));de(this.gl,this.program,new Float32Array(r.flat()),2,"a_clipTrianglePoint");const s=this.previousTrianglePointsDistortion;de(this.gl,this.program,new Float32Array(s),1,"a_previousTrianglePointDistortion");const n=this.trianglePointsDistortion;de(this.gl,this.program,new Float32Array(n),1,"a_trianglePointDistortion");const o=new Float32Array(this.resourceTrianglePoints.length).map((a,h)=>Math.round((h-1)/3));de(this.gl,this.program,o,1,"a_triangleIndex")}async updateTextures(){const e=this.gl;if(this.CachedTilesByTileUrl.size===0)return;let t=[...this.CachedTilesByTileUrl.values()];t=t.filter(l=>this.resourceViewportRingBbox?Ra(jo(l.tile),this.resourceViewportRingBbox):!0);const r=t.length,s=t.map((l,u)=>({w:l.data.width,h:l.data.height,x:0,y:0,index:u})),{w:n,h:o}=ed(s);e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.bindTexture(e.TEXTURE_2D,this.packedTilesTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n,o,0,e.RGBA,e.UNSIGNED_BYTE,null);for(const l of s){const u=t[l.index].data;e.texSubImage2D(e.TEXTURE_2D,0,l.x,l.y,u.width,u.height,e.RGBA,e.UNSIGNED_BYTE,u)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);const a=s.map(l=>[l.x,l.y]);e.bindTexture(e.TEXTURE_2D,this.packedTilesPositionsTexture),e.texImage2D(e.TEXTURE_2D,0,e.RG32I,1,r,0,e.RG_INTEGER,e.INT,new Int32Array(a.flat())),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);const h=s.map(l=>{const u=t[l.index];if(u&&u.imageRequest&&u.imageRequest.region)return[u.imageRequest.region.x,u.imageRequest.region.y,u.imageRequest.region.width,u.imageRequest.region.height]});e.bindTexture(e.TEXTURE_2D,this.packedTilesResourcePositionsAndDimensionsTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32I,1,r,0,e.RGBA_INTEGER,e.INT,new Int32Array(h.flat())),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);const c=s.map(({index:l})=>t[l].tile.tileZoomLevel.scaleFactor);e.bindTexture(e.TEXTURE_2D,this.packedTilesScaleFactorsTexture),e.texImage2D(e.TEXTURE_2D,0,e.R32I,1,r,0,e.RED_INTEGER,e.INT,new Int32Array(c)),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),this.dispatchEvent(new Z(k.TEXTURESUPDATED))}};const qd=v.string().or(v.number()).or(v.boolean()),$d=v.record(v.string(),qd.array()),se=v.tuple([v.number(),v.number()]),Lo=v.object({type:v.literal("Point"),coordinates:se}),Oo=se.array().min(3),hr=v.enum(["ImageService1","ImageService2","ImageService3"]),Xd=v.object({id:v.string().url(),type:v.string(),label:$d.optional()}),ui=Xd.extend({partOf:v.lazy(()=>ui.array()).optional()}),di=v.union([v.any(),v.object({type:v.string(),options:v.object({}).optional()})]).transform(i=>{if(i&&typeof i=="object"&&"type"in i)return i}),pi=v.union([v.string().url().array(),v.string().url()]),Hd=/^<svg\s+width="\d+"\s+height="\d+"\s*>\s*<polygon\s+points="\s*(-?\d+(\.\d+)?,-?\d+(\.\d+)?\s+){2,}-?\d+(\.\d+)?,-?\d+(\.\d+)?\s*"\s*\/>\s*<\/svg>$/,Yd=v.object({type:v.literal("SvgSelector"),value:v.string().regex(Hd)}),Kd=v.object({source:v.string().url(),service:v.array(v.object({"@id":v.string().url(),type:hr})).length(1),selector:Yd}),Do=v.object({pixelCoords:se}),Jd=v.object({type:v.literal("FeatureCollection"),transformation:di.optional(),features:v.array(v.object({type:v.literal("Feature"),properties:Do,geometry:Lo}))}),ys=v.object({id:v.string().optional(),type:v.literal("Annotation"),"@context":pi.optional(),motivation:v.string().default("georeferencing").optional(),target:Kd,body:Jd}),No=v.object({id:v.string().optional(),type:v.literal("AnnotationPage"),"@context":pi.optional(),items:v.array(ys)}),vs=/<polygon\s+points="\s*(-?\d+(\.\d+)?,-?\d+(\.\d+)?\s+){2,}-?\d+(\.\d+)?,-?\d+(\.\d+)?\s*"\s*\/>/,Qd=new RegExp(`^<svg\\s+width="\\d+"\\s+height="\\d+"\\s*>\\s*${vs.source}\\s*</svg>$`),tp=new RegExp(`^<svg\\s+height="\\d+"\\s+width="\\d+"\\s*>\\s*${vs.source}\\s*</svg>$`),ep=new RegExp(`^<svg\\s*>\\s*${vs.source}\\s*</svg>$`),rp=v.string().regex(ep),ip=v.string().regex(Qd),sp=v.string().regex(tp),np=v.object({type:v.literal("SvgSelector"),value:rp.or(ip).or(sp)}),op=v.object({"@id":v.string().url(),type:hr,height:v.number().positive(),width:v.number().positive(),partOf:ui.array().optional()}),ap=v.object({id:v.string().url(),type:hr,height:v.number().positive(),width:v.number().positive(),partOf:ui.array().optional()}),hp=v.object({type:v.literal("SpecificResource"),source:op.or(ap),selector:np}),Fo=v.object({resourceCoords:se}),cp=v.object({type:v.literal("FeatureCollection"),transformation:di.optional(),features:v.array(v.object({type:v.literal("Feature"),properties:Fo,geometry:Lo}))}),ws=v.object({id:v.string().optional(),type:v.literal("Annotation"),"@context":pi.optional(),motivation:v.string().default("georeferencing").optional(),created:v.string().datetime().optional(),modified:v.string().datetime().optional(),target:hp,body:cp}),Go=v.object({id:v.string().optional(),type:v.literal("AnnotationPage"),"@context":pi.optional(),items:v.array(ws)});ys.or(ws);No.or(Go);Do.or(Fo);function Bo(i){return Array.isArray(i)}function lp(i){return!!(i&&typeof i=="object"&&"type"in i&&i.type==="AnnotationPage")}function ti(i){return!!(i&&typeof i=="object"&&"type"in i&&i.type==="GeoreferencedMap")}function rn(i){return!!(i&&typeof i=="object"&&"target"in i&&i.target&&typeof i.target=="object"&&"source"in i.target&&typeof i.target.source=="string")}function fi(i){return"type"in i&&i.type==="GeoreferencedMap"}function mi(i){return"source"in i.target&&typeof i.target.source=="object"}function up(i){return{id:dp(i),...vp(i),type:pp(i),partOf:fp(i)}}function dp(i){if(mi(i)){const e=i.target.source;return"id"in e?e.id:e["@id"]}else return i.target.service[0]["@id"]}function pp(i){return"service"in i.target?i.target.service[0].type:i.target.source.type}function fp(i){if(mi(i))return i.target.source.partOf}function mp(i){return"pixelCoords"in i?i.pixelCoords:i.resourceCoords}function gp(i){return i.body.features.map(e=>({resource:mp(e.properties),geo:e.geometry.coordinates}))}function yp(i){if(mi(i))return{created:i.created,modified:i.modified}}function vp(i){var o,a;if(mi(i))return{width:i.target.source.width,height:i.target.source.height};const e=i.target.selector.value,t=/width="(?<width>\d+)"/.exec(e),r=/height="(?<height>\d+)"/.exec(e),s=(o=t==null?void 0:t.groups)==null?void 0:o.width,n=(a=r==null?void 0:r.groups)==null?void 0:a.height;if(!s||!n)throw new Error("Could not parse image dimensions");return{width:parseInt(s),height:parseInt(n)}}function wp(i){var r;const e=i.target.selector.value,t=(r=/points="(?<points>.+)"/.exec(e))==null?void 0:r.groups;if(t&&t.points){const s=t.points.trim().split(/\s+/);if(s[0]===s[s.length-1]&&s.splice(-1),s.length>=3)return s.map(n=>{const o=n.split(",");if(o.length===2)return[parseFloat(o[0]),parseFloat(o[1])];throw new Error("Could not parse resource mask")});throw new Error("Could not parse resource mask")}else throw new Error("Could not parse resource mask")}function sn(i){return{"@context":"https://schemas.allmaps.org/map/2/context.json",type:"GeoreferencedMap",id:i.id,...yp(i),resource:up(i),gcps:gp(i),resourceMask:wp(i),transformation:i.body.transformation}}function Yi(i){if(lp(i)){let e;return"items"in i&&Array.isArray(i.items)&&rn(i.items[0])?e=No.parse(i):e=Go.parse(i),e.items.map(t=>sn(t))}else{let e;return rn(i)?e=ys.parse(i):e=ws.parse(i),[sn(e)]}}const Uo=v.object({image:se,world:se}),xp=v.object({uri:v.string().url(),width:v.number(),height:v.number(),type:hr}),gi=v.object({id:v.string().optional(),version:v.number().min(1).max(1).default(1),image:xp,gcps:Uo.array(),pixelMask:Oo,transformation:di.optional()}),xs=v.array(gi),zo=v.object({resource:se,geo:se}),bp=v.object({id:v.string().url(),width:v.number(),height:v.number(),type:hr,partOf:ui.array().optional()}),yi=v.object({"@context":v.literal("https://schemas.allmaps.org/map/2/context.json").optional(),type:v.literal("GeoreferencedMap"),id:v.string().optional(),created:v.string().datetime().optional(),modified:v.string().datetime().optional(),resource:bp,gcps:zo.array(),resourceMask:Oo,transformation:di.optional()}),bs=v.array(yi);gi.or(yi);xs.or(bs);Uo.or(zo);function Mp(i){let e,t,r;return fi(i)?(e=i.resource.width,t=i.resource.height,r=i.resourceMask):(e=i.image.width,t=i.image.height,r=i.pixelMask),{type:"SvgSelector",value:`<svg width="${e}" height="${t}"><polygon points="${r.map(s=>s.join(",")).join(" ")}" /></svg>`}}function Ep(i){let e,t,r,s,n;return fi(i)?(e=i.resource.id,t=i.resource.type,r=i.resource.width,s=i.resource.height,n=i.resource.partOf):(e=i.image.uri,t=i.image.type,r=i.image.width,s=i.image.height),{id:e,type:t,height:s,width:r,partOf:n}}function _p(i){if(fi(i))return{created:i.created,modified:i.modified}}function Tp(){return["http://iiif.io/api/extension/georef/1/context.json","http://iiif.io/api/presentation/3/context.json"]}function Pp(i){let e,t;return"resource"in i?(e=i.resource,t=i.geo):(e=i.image,t=i.world),{type:"Feature",properties:{resourceCoords:e},geometry:{type:"Point",coordinates:t}}}function nn(i){const e={type:"SpecificResource",source:Ep(i),selector:Mp(i)},t={type:"FeatureCollection",transformation:i.transformation,features:i.gcps.map(r=>Pp(r))};return{id:i.id,type:"Annotation","@context":Tp(),..._p(i),motivation:"georeferencing",target:e,body:t}}function Ip(i){if(Bo(i)){let e;return ti(i[0])?e=bs.parse(i):e=xs.parse(i),{type:"AnnotationPage","@context":"http://www.w3.org/ns/anno.jsonld",items:e.map(t=>nn(t))}}else{let e;return ti(i)?e=yi.parse(i):e=gi.parse(i),nn(e)}}function Wo(i){return fi(i)?i:Yi(Ip(i))[0]}function Rp(i){return i.map(Wo)}function on(i){if(Bo(i)){let e;return ti(i[0])?e=bs.parse(i):e=xs.parse(i),Rp(e)}else{let e;return ti(i)?e=yi.parse(i):e=gi.parse(i),Wo(e)}}function Sp(i,e,t,r,s){Zo(i,e,t||0,r||i.length-1,s||Ap)}function Zo(i,e,t,r,s){for(;r>t;){if(r-t>600){var n=r-t+1,o=e-t+1,a=Math.log(n),h=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*h*(n-h)/n)*(o-n/2<0?-1:1),l=Math.max(t,Math.floor(e-o*h/n+c)),u=Math.min(r,Math.floor(e+(n-o)*h/n+c));Zo(i,e,l,u,s)}var m=i[e],g=t,y=r;for(je(i,t,e),s(i[r],m)>0&&je(i,t,r);g<y;){for(je(i,g,y),g++,y--;s(i[g],m)<0;)g++;for(;s(i[y],m)>0;)y--}s(i[t],m)===0?je(i,t,y):(y++,je(i,y,r)),y<=e&&(t=y+1),e<=y&&(r=y-1)}}function je(i,e,t){var r=i[e];i[e]=i[t],i[t]=r}function Ap(i,e){return i<e?-1:i>e?1:0}class Cp{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const r=[];if(!Sr(e,t))return r;const s=this.toBBox,n=[];for(;t;){for(let o=0;o<t.children.length;o++){const a=t.children[o],h=t.leaf?s(a):a;Sr(e,h)&&(t.leaf?r.push(a):ji(e,h)?this._all(a,r):n.push(a))}t=n.pop()}return r}collides(e){let t=this.data;if(!Sr(e,t))return!1;const r=[];for(;t;){for(let s=0;s<t.children.length;s++){const n=t.children[s],o=t.leaf?this.toBBox(n):n;if(Sr(e,o)){if(t.leaf||ji(e,o))return!0;r.push(n)}}t=r.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let r=0;r<e.length;r++)this.insert(e[r]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const r=this.data;this.data=t,t=r}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=ve([]),this}remove(e,t){if(!e)return this;let r=this.data;const s=this.toBBox(e),n=[],o=[];let a,h,c;for(;r||n.length;){if(r||(r=n.pop(),h=n[n.length-1],a=o.pop(),c=!0),r.leaf){const l=kp(e,r.children,t);if(l!==-1)return r.children.splice(l,1),n.push(r),this._condense(n),this}!c&&!r.leaf&&ji(r,s)?(n.push(r),o.push(a),a=0,h=r,r=r.children[0]):h?(a++,r=h.children[a],c=!1):r=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){const r=[];for(;e;)e.leaf?t.push(...e.children):r.push(...e.children),e=r.pop();return t}_build(e,t,r,s){const n=r-t+1;let o=this._maxEntries,a;if(n<=o)return a=ve(e.slice(t,r+1)),pe(a,this.toBBox),a;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),a=ve([]),a.leaf=!1,a.height=s;const h=Math.ceil(n/o),c=h*Math.ceil(Math.sqrt(o));an(e,t,r,c,this.compareMinX);for(let l=t;l<=r;l+=c){const u=Math.min(l+c-1,r);an(e,l,u,h,this.compareMinY);for(let m=l;m<=u;m+=h){const g=Math.min(m+h-1,u);a.children.push(this._build(e,m,g,s-1))}}return pe(a,this.toBBox),a}_chooseSubtree(e,t,r,s){for(;s.push(t),!(t.leaf||s.length-1===r);){let n=1/0,o=1/0,a;for(let h=0;h<t.children.length;h++){const c=t.children[h],l=ki(c),u=Op(e,c)-l;u<o?(o=u,n=l<n?l:n,a=c):u===o&&l<n&&(n=l,a=c)}t=a||t.children[0]}return t}_insert(e,t,r){const s=r?e:this.toBBox(e),n=[],o=this._chooseSubtree(s,this.data,t,n);for(o.children.push(e),Be(o,s);t>=0&&n[t].children.length>this._maxEntries;)this._split(n,t),t--;this._adjustParentBBoxes(s,n,t)}_split(e,t){const r=e[t],s=r.children.length,n=this._minEntries;this._chooseSplitAxis(r,n,s);const o=this._chooseSplitIndex(r,n,s),a=ve(r.children.splice(o,r.children.length-o));a.height=r.height,a.leaf=r.leaf,pe(r,this.toBBox),pe(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(r,a)}_splitRoot(e,t){this.data=ve([e,t]),this.data.height=e.height+1,this.data.leaf=!1,pe(this.data,this.toBBox)}_chooseSplitIndex(e,t,r){let s,n=1/0,o=1/0;for(let a=t;a<=r-t;a++){const h=Ge(e,0,a,this.toBBox),c=Ge(e,a,r,this.toBBox),l=Dp(h,c),u=ki(h)+ki(c);l<n?(n=l,s=a,o=u<o?u:o):l===n&&u<o&&(o=u,s=a)}return s||r-t}_chooseSplitAxis(e,t,r){const s=e.leaf?this.compareMinX:jp,n=e.leaf?this.compareMinY:Lp,o=this._allDistMargin(e,t,r,s),a=this._allDistMargin(e,t,r,n);o<a&&e.children.sort(s)}_allDistMargin(e,t,r,s){e.children.sort(s);const n=this.toBBox,o=Ge(e,0,t,n),a=Ge(e,r-t,r,n);let h=Rr(o)+Rr(a);for(let c=t;c<r-t;c++){const l=e.children[c];Be(o,e.leaf?n(l):l),h+=Rr(o)}for(let c=r-t-1;c>=t;c--){const l=e.children[c];Be(a,e.leaf?n(l):l),h+=Rr(a)}return h}_adjustParentBBoxes(e,t,r){for(let s=r;s>=0;s--)Be(t[s],e)}_condense(e){for(let t=e.length-1,r;t>=0;t--)e[t].children.length===0?t>0?(r=e[t-1].children,r.splice(r.indexOf(e[t]),1)):this.clear():pe(e[t],this.toBBox)}}function kp(i,e,t){if(!t)return e.indexOf(i);for(let r=0;r<e.length;r++)if(t(i,e[r]))return r;return-1}function pe(i,e){Ge(i,0,i.children.length,e,i)}function Ge(i,e,t,r,s){s||(s=ve(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let n=e;n<t;n++){const o=i.children[n];Be(s,i.leaf?r(o):o)}return s}function Be(i,e){return i.minX=Math.min(i.minX,e.minX),i.minY=Math.min(i.minY,e.minY),i.maxX=Math.max(i.maxX,e.maxX),i.maxY=Math.max(i.maxY,e.maxY),i}function jp(i,e){return i.minX-e.minX}function Lp(i,e){return i.minY-e.minY}function ki(i){return(i.maxX-i.minX)*(i.maxY-i.minY)}function Rr(i){return i.maxX-i.minX+(i.maxY-i.minY)}function Op(i,e){return(Math.max(e.maxX,i.maxX)-Math.min(e.minX,i.minX))*(Math.max(e.maxY,i.maxY)-Math.min(e.minY,i.minY))}function Dp(i,e){const t=Math.max(i.minX,e.minX),r=Math.max(i.minY,e.minY),s=Math.min(i.maxX,e.maxX),n=Math.min(i.maxY,e.maxY);return Math.max(0,s-t)*Math.max(0,n-r)}function ji(i,e){return i.minX<=e.minX&&i.minY<=e.minY&&e.maxX<=i.maxX&&e.maxY<=i.maxY}function Sr(i,e){return e.minX<=i.maxX&&e.minY<=i.maxY&&e.maxX>=i.minX&&e.maxY>=i.minY}function ve(i){return{children:i,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function an(i,e,t,r,s){const n=[e,t];for(;n.length;){if(t=n.pop(),e=n.pop(),t-e<=r)continue;const o=e+Math.ceil((t-e)/r/2)*r;Sp(i,o,e,t,s),n.push(e,o,o,t)}}function Np(i,e,t){if(t===void 0&&(t={}),!i)throw new Error("point is required");if(!e)throw new Error("polygon is required");var r=Te(i),s=Rc(e),n=s.type,o=e.bbox,a=s.coordinates;if(o&&Fp(r,o)===!1)return!1;n==="Polygon"&&(a=[a]);for(var h=!1,c=0;c<a.length&&!h;c++)if(hn(r,a[c][0],t.ignoreBoundary)){for(var l=!1,u=1;u<a[c].length&&!l;)hn(r,a[c][u],!t.ignoreBoundary)&&(l=!0),u++;l||(h=!0)}return h}function hn(i,e,t){var r=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var s=0,n=e.length-1;s<e.length;n=s++){var o=e[s][0],a=e[s][1],h=e[n][0],c=e[n][1],l=i[1]*(o-h)+a*(h-i[0])+c*(i[0]-o)===0&&(o-i[0])*(h-i[0])<=0&&(a-i[1])*(c-i[1])<=0;if(l)return!t;var u=a>i[1]!=c>i[1]&&i[0]<(h-o)*(i[1]-a)/(c-a)+o;u&&(r=!r)}return r}function Fp(i,e){return e[0]<=i[0]&&e[1]<=i[1]&&e[2]>=i[0]&&e[3]>=i[1]}const Gp=!0;let Bp=class{constructor(){M(this,"rbush",new Cp);M(this,"polygonsById",new Map);M(this,"bboxesById",new Map);M(this,"itemsById",new Map)}addItem(i,e){this.removeItem(i);const t=dt(e),r={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],id:i};this.polygonsById.set(i,e),this.bboxesById.set(i,t),this.itemsById.set(i,r),this.rbush.insert(r)}removeItem(i){const e=this.itemsById.get(i);e&&(this.rbush.remove(e),this.polygonsById.delete(i),this.bboxesById.delete(i),this.itemsById.delete(i))}clear(){this.polygonsById.clear(),this.bboxesById.clear(),this.itemsById.clear(),this.rbush.clear()}search(i,e,t,r){return this.rbush.search({minX:i,minY:e,maxX:t,maxY:r})}getBbox(i){return this.bboxesById.get(i)}getPolygon(i){return this.polygonsById.get(i)}searchFromBbox(i){const[e,t,r,s]=i;return this.search(e,t,r,s).map(n=>n.id)}searchFromPoint(i,e=Gp){const[t,r,s,n]=[i[0],i[1],i[0],i[1]],o=this.search(t,r,s,n);return e?o.filter(a=>{const h=this.polygonsById.get(a.id);return h?Np(i,h):!1}).map(a=>a.id):o.map(a=>a.id)}};function Up(){return{createRTree:!0,imageInformations:new Map}}let zp=class extends EventTarget{constructor(e,t){super();M(this,"warpedMapFactory");M(this,"warpedMapsById",new Map);M(this,"zIndices",new Map);M(this,"rtree");M(this,"imageInformations");M(this,"transformation");M(this,"fetchFn");this.warpedMapFactory=e,t={...Up(),...t},this.fetchFn=t==null?void 0:t.fetchFn,this.imageInformations=t.imageInformations,this.transformation=t.transformation,t.createRTree&&(this.rtree=new Bp)}getMapIds(){return this.warpedMapsById.keys()}getWarpedMaps(e){if(e===void 0)return this.warpedMapsById.values();{const t=[];for(const r of e){const s=this.warpedMapsById.get(r);s&&t.push(s)}return t}}getWarpedMap(e){return this.warpedMapsById.get(e)}getMapZIndex(e){return this.zIndices.get(e)}getCenter(){const e=this.getBbox();if(e)return be(e)}getProjectedCenter(){const e=this.getProjectedBbox();if(e)return be(e)}getBbox(){let e;for(const t of this.getWarpedMaps())t.visible&&(e?e=Ps(e,t.geoMaskBbox):e=t.geoMaskBbox);return e}getProjectedBbox(){let e;for(const t of this.getWarpedMaps())t.visible&&(e?e=Ps(e,t.projectedGeoMaskBbox):e=t.projectedGeoMaskBbox);return e}getMapsByGeoBbox(e){return this.rtree?this.rtree.searchFromBbox(e):Array.from(this.warpedMapsById.keys())}setImageInformations(e){this.imageInformations=e}setMapResourceMask(e,t){const r=this.warpedMapsById.get(e);r&&(r.setResourceMask(t),this.addToOrUpdateRtree(r),this.dispatchEvent(new Z(k.RESOURCEMASKUPDATED,e)))}setMapsTransformationType(e,t){const r=[];for(const s of e){const n=this.warpedMapsById.get(s);n&&n.transformationType!=t&&(n.setTransformationType(t),this.addToOrUpdateRtree(n),r.push(s))}r.length>0&&this.dispatchEvent(new Z(k.TRANSFORMATIONCHANGED,r))}setMapsDistortionMeasure(e,t){const r=[];for(const s of e){const n=this.warpedMapsById.get(s);n&&n.distortionMeasure!=t&&(n.setDistortionMeasure(t),r.push(s))}r.length>0&&this.dispatchEvent(new Z(k.DISTORTIONCHANGED,r))}bringMapsToFront(e){let t=this.warpedMapsById.size;for(const r of e)this.zIndices.has(r)&&(this.zIndices.set(r,t),t++);this.removeZIndexHoles(),this.dispatchEvent(new Z(k.ZINDICESCHANGES))}sendMapsToBack(e){let t=-Array.from(e).length;for(const r of e)this.zIndices.has(r)&&(this.zIndices.set(r,t),t++);this.removeZIndexHoles(),this.dispatchEvent(new Z(k.ZINDICESCHANGES))}bringMapsForward(e){for(const[t,r]of this.zIndices.entries())this.zIndices.set(t,r*2);for(const t of e){const r=this.zIndices.get(t);r!==void 0&&this.zIndices.set(t,r+3)}this.removeZIndexHoles(),this.dispatchEvent(new Z(k.ZINDICESCHANGES))}sendMapsBackward(e){for(const[t,r]of this.zIndices.entries())this.zIndices.set(t,r*2);for(const t of e){const r=this.zIndices.get(t);r!==void 0&&this.zIndices.set(t,r-3)}this.removeZIndexHoles(),this.dispatchEvent(new Z(k.ZINDICESCHANGES))}showMaps(e){for(const t of e){const r=this.warpedMapsById.get(t);r&&(r.visible=!0)}this.dispatchEvent(new Z(k.VISIBILITYCHANGED,e))}hideMaps(e){for(const t of e){const r=this.warpedMapsById.get(t);r&&(r.visible=!1)}this.dispatchEvent(new Z(k.VISIBILITYCHANGED,e))}async addGeoreferencedMap(e){const t=on(e),r=Array.isArray(t)?t[0]:t;return this.addGeoreferencedMapInternal(r)}async removeGeoreferencedMap(e){const t=on(e),r=Array.isArray(t)?t[0]:t;return this.removeGeoreferencedMapInternal(r)}async addGeoreferenceAnnotation(e){const t=[],r=Yi(e),s=await Promise.allSettled(r.map(n=>this.addGeoreferencedMapInternal(n)));for(const n of s)n.status==="fulfilled"?t.push(n.value):t.push(n.reason);return this.dispatchEvent(new Z(k.GEOREFERENCEANNOTATIONADDED)),this.dispatchEvent(new Z(k.ZINDICESCHANGES)),t}async removeGeoreferenceAnnotation(e){const t=[],r=Yi(e);for(const s of r){const n=await this.removeGeoreferencedMapInternal(s);t.push(n)}return this.dispatchEvent(new Z(k.GEOREFERENCEANNOTATIONREMOVED)),t}clear(){var e;this.warpedMapsById=new Map,this.zIndices=new Map,(e=this.rtree)==null||e.clear(),this.dispatchEvent(new Z(k.CLEARED))}dispose(){for(const e of this.getWarpedMaps())this.removeEventListenersFromWarpedMap(e),e.dispose()}async addGeoreferencedMapInternal(e){const t=await this.getOrComputeMapId(e),r=this.warpedMapFactory(t,e,{imageInformations:this.imageInformations,fetchFn:this.fetchFn,transformation:this.transformation});return this.warpedMapsById.set(t,r),this.zIndices.set(t,this.warpedMapsById.size-1),this.addToOrUpdateRtree(r),this.addEventListenersToWarpedMap(r),this.dispatchEvent(new Z(k.WARPEDMAPADDED,t)),t}async removeGeoreferencedMapInternal(e){const t=await this.getOrComputeMapId(e),r=this.warpedMapsById.get(t);if(r)this.warpedMapsById.delete(t),this.zIndices.delete(t),this.removeFromRtree(r),this.dispatchEvent(new Z(k.WARPEDMAPREMOVED,t)),this.removeZIndexHoles(),this.dispatchEvent(new Z(k.ZINDICESCHANGES));else throw new Error(`No map found with ID ${t}`);return t}async getOrComputeMapId(e){return e.id||await Wa(e)}addToOrUpdateRtree(e){this.rtree&&(this.rtree.removeItem(e.mapId),this.rtree.addItem(e.mapId,e.geoMask))}removeFromRtree(e){this.rtree&&this.rtree.removeItem(e.mapId)}removeZIndexHoles(){const e=[...this.zIndices.entries()].sort((r,s)=>r[1]-s[1]);let t=0;for(const r of e){const s=r[0];this.zIndices.set(s,t),t++}}imageInfoLoaded(){this.dispatchEvent(new Z(k.IMAGEINFOLOADED))}addEventListenersToWarpedMap(e){e.addEventListener(k.IMAGEINFOLOADED,this.imageInfoLoaded.bind(this))}removeEventListenersFromWarpedMap(e){e.removeEventListener(k.IMAGEINFOLOADED,this.imageInfoLoaded.bind(this))}};class Wp extends EventTarget{constructor(t,r){super();M(this,"tile");M(this,"imageRequest");M(this,"tileUrl");M(this,"fetchFn");M(this,"abortController");M(this,"data");this.tile=t.tile,this.imageRequest=t.imageRequest,this.tileUrl=t.tileUrl,this.fetchFn=r,this.abortController=new AbortController}isCachedTile(){return this.data!==void 0}abort(){this.abortController.signal.aborted||this.abortController.abort()}}class Zp{constructor(e,t){M(this,"mapId");M(this,"tile");M(this,"imageRequest");M(this,"tileUrl");this.mapId=t.mapId,this.tile=e;const r=t.parsedImage.getIiifTile(e.tileZoomLevel,e.column,e.row);this.imageRequest=r,this.tileUrl=t.parsedImage.getImageUrl(r)}}class Ms extends Wp{async fetch(){try{const e=await(await ln(this.tileUrl,{signal:this.abortController.signal},this.fetchFn)).blob();this.data=await createImageBitmap(e),this.dispatchEvent(new Z(k.TILEFETCHED,this.tileUrl))}catch(e){e instanceof Error&&e.name==="AbortError"||this.dispatchEvent(new Z(k.TILEFETCHERROR,this.tileUrl))}return this.data}static createFactory(){return(e,t)=>new Ms(e,t)}}const Vp=0,qp=32*1e3*1e3;class $p extends EventTarget{constructor(t,r){super();M(this,"cachableTileFactory");M(this,"fetchFn");M(this,"tilesByTileUrl",new Map);M(this,"mapIdsByTileUrl",new Map);M(this,"tileUrlsByMapId",new Map);M(this,"tilesFetchingCount",0);M(this,"previousRequestedTiles",[]);M(this,"outgoingTilesHistory",[]);this.cachableTileFactory=t,this.fetchFn=r==null?void 0:r.fetchFn}getCacheableTile(t){return this.tilesByTileUrl.get(t)}getCachedTile(t){const r=this.tilesByTileUrl.get(t);if(r&&r.isCachedTile())return r}getCacheableTiles(){return this.tilesByTileUrl.values()}getCachedTiles(){const t=[];for(const r of this.tilesByTileUrl.values())r.isCachedTile()&&t.push(r);return t}getCachedTilesForMapId(t){var s;const r=[];for(const n of this.tilesByTileUrl.values())n.isCachedTile()&&((s=this.tileUrlsByMapId.get(t))!=null&&s.has(n.tileUrl))&&r.push(n);return r}getTileUrls(){return this.tilesByTileUrl.keys()}requestFetchableTiles(t){const r=Ci(this.previousRequestedTiles),s=Ci(t);if(ka(r,s))return;const n=[];for(const h of this.previousRequestedTiles)s.has(ko(h))||n.push(h);this.updateOutgoingTilesHistory(n,t.length);const o=Ci(this.outgoingTilesHistory),a=new Set([...s,...o]);for(const[h,c]of this.mapIdsByTileUrl)for(const l of c)a.has(Co(l,h))||this.removeMapTile(l,h);for(const h of t)this.addMapTile(h);this.previousRequestedTiles=t}async allRequestedTilesLoaded(){return new Promise(t=>{if(this.finished)t();else{const r=()=>{this.removeEventListener(k.ALLREQUESTEDTILESLOADED,r),t()};this.addEventListener(k.ALLREQUESTEDTILESLOADED,r)}})}getTileUrlsForMapId(t){return this.tileUrlsByMapId.get(t)||new Set}clear(){this.tilesByTileUrl=new Map,this.mapIdsByTileUrl=new Map,this.tileUrlsByMapId=new Map,this.tilesFetchingCount=0,this.outgoingTilesHistory=[]}dispose(){for(const t of this.getCacheableTiles())this.removeEventListenersFromTile(t)}addMapTile(t){const r=t.mapId,s=t.tileUrl;if(this.tilesByTileUrl.has(s))this.dispatchEvent(new Z(k.MAPTILELOADED,{mapId:r,tileUrl:s}));else{const n=this.cachableTileFactory(t,this.fetchFn);this.addEventListenersToTile(n),this.tilesByTileUrl.set(s,n),this.updateTilesFetchingCount(1),n.fetch()}this.addTileUrlForMapId(r,s),this.addMapIdForTileUrl(r,s)}removeMapTile(t,r){const s=this.tilesByTileUrl.get(r);if(!s)return;const n=this.removeMapIdForTileUrl(t,r);this.removeTileUrlForMapId(t,r),n.size||(s.isCachedTile()||(s.abort(),this.updateTilesFetchingCount(-1)),this.tilesByTileUrl.delete(r)),this.dispatchEvent(new Z(k.MAPTILEREMOVED,{mapId:t,tileUrl:r}))}updateOutgoingTilesHistory(t,r){for(let a=t.length-1;a>=0;a--){const h=t[a];this.outgoingTilesHistory.unshift(h)}this.outgoingTilesHistory=Array.from(new Set(this.outgoingTilesHistory));let s=0,n=0,o=0;for(const a of this.outgoingTilesHistory){if(s+=1,o=Dd(a),n+=o,s+r>Vp){s-=1,n-=o;break}if(n>qp){s-=1,n-=o;break}}this.outgoingTilesHistory=this.outgoingTilesHistory.slice(0,s)}tileFetched(t){var r;if(t instanceof Z){const s=t.data;this.updateTilesFetchingCount(-1);for(const n of this.mapIdsByTileUrl.get(s)||[])this.dispatchEvent(new Z(k.MAPTILELOADED,{mapId:n,tileUrl:s})),((r=this.tileUrlsByMapId.get(n))==null?void 0:r.values().next().value)===s&&this.dispatchEvent(new Z(k.FIRSTMAPTILELOADED,{mapId:n,tileUrl:s}))}}tileFetchError(t){if(t instanceof Z){const r=t.data;this.tilesByTileUrl.has(r)||this.updateTilesFetchingCount(-1)}}addMapIdForTileUrl(t,r){let s=this.mapIdsByTileUrl.get(r);return s?s.add(t):s=new Set([t]),this.mapIdsByTileUrl.set(r,s),s}removeMapIdForTileUrl(t,r){const s=this.mapIdsByTileUrl.get(r);if(s)s.delete(t);else return new Set;return s.size?this.mapIdsByTileUrl.set(r,s):this.mapIdsByTileUrl.delete(r),s}addTileUrlForMapId(t,r){let s=this.tileUrlsByMapId.get(t);return s?s.add(r):s=new Set([r]),this.tileUrlsByMapId.set(t,s),s}removeTileUrlForMapId(t,r){const s=this.tileUrlsByMapId.get(t);return s?(s.delete(r),s.size?this.tileUrlsByMapId.set(t,s):this.tileUrlsByMapId.delete(t),s):new Set}get finished(){return this.tilesFetchingCount===0}updateTilesFetchingCount(t){this.tilesFetchingCount+=t,this.tilesFetchingCount===0&&this.dispatchEvent(new Z(k.ALLREQUESTEDTILESLOADED))}addEventListenersToTile(t){t.addEventListener(k.TILEFETCHED,this.tileFetched.bind(this)),t.addEventListener(k.TILEFETCHERROR,this.tileFetchError.bind(this))}removeEventListenersFromTile(t){t.removeEventListener(k.TILEFETCHED,this.tileFetched.bind(this)),t.removeEventListener(k.TILEFETCHERROR,this.tileFetchError.bind(this))}}const Xp=5;class Hp extends EventTarget{constructor(t,r,s){super();M(this,"warpedMapList");M(this,"tileCache");M(this,"mapsInViewport",new Set);M(this,"viewport");this.tileCache=new $p(t,s),this.warpedMapList=new zp(r,s)}async addGeoreferenceAnnotation(t){return this.warpedMapList.addGeoreferenceAnnotation(t)}async addGeoreferencedMap(t){return this.warpedMapList.addGeoreferencedMap(t)}loadMissingImageInfosInViewport(){return this.viewport?Array.from(this.warpedMapList.getMapsByGeoBbox(this.viewport.geoRectangleBbox)).map(t=>this.warpedMapList.getWarpedMap(t)).filter(t=>!t.hasImageInfo()&&!t.loadingImageInfo).map(t=>t.loadImageInfo()):[]}someImageInfosInViewport(){return this.viewport?Array.from(this.warpedMapList.getMapsByGeoBbox(this.viewport.geoRectangleBbox)).map(t=>this.warpedMapList.getWarpedMap(t)).map(t=>t.hasImageInfo()).some(t=>t===!0):!1}shouldUpdateRequestedTiles(){return!0}updateRequestedTiles(){if(!this.viewport)return;const t=this.viewport;if(!this.shouldUpdateRequestedTiles())return;const r=Array.from(this.warpedMapList.getMapsByGeoBbox(this.viewport.geoRectangleBbox)).sort((n,o)=>{const a=this.warpedMapList.getWarpedMap(n),h=this.warpedMapList.getWarpedMap(o);return a&&h?bt(be(a.geoMaskBbox),t.geoCenter)-bt(be(h.geoMaskBbox),t.geoCenter):0}),s=[];for(const n of r){const o=this.warpedMapList.getWarpedMap(n);if(!o||!o.visible||!o.hasImageInfo()||Sa(o.getViewportMaskBbox(t))<Xp)continue;const a=Ad(o.parsedImage,o.getResourceToCanvasScale(t));o.setBestScaleFactor(a.scaleFactor);const h={maxDepth:0,sourceIsGeographic:!1,destinationIsGeographic:!0},c=o.transformer.transformBackward([t.geoRectangle],h)[0];o.setResourceViewportRing(c);const l=Cd(c,a,o.parsedImage);for(const u of l)s.push(new Zp(u,o))}this.tileCache.requestFetchableTiles(s),this.updateMapsInViewport(s)}updateMapsInViewport(t){const r=Array.from(this.mapsInViewport),s=t.map(a=>a.mapId).filter((a,h,c)=>c.indexOf(a)===h);this.mapsInViewport=new Set(s.sort((a,h)=>{const c=this.warpedMapList.getMapZIndex(a),l=this.warpedMapList.getMapZIndex(h);return c!==void 0&&l!==void 0?c-l:0}));const n=s.filter(a=>!r.includes(a)),o=r.filter(a=>!s.includes(a));for(const a in n)this.dispatchEvent(new Z(k.WARPEDMAPENTER,a));for(const a in o)this.dispatchEvent(new Z(k.WARPEDMAPLEAVE,a))}mapTileLoaded(t){}mapTileRemoved(t){}imageInfoLoaded(t){}warpedMapAdded(t){}warpedMapRemoved(t){}transformationChanged(t){}distortionChanged(t){}addEventListeners(){this.tileCache.addEventListener(k.MAPTILELOADED,this.mapTileLoaded.bind(this)),this.tileCache.addEventListener(k.MAPTILEREMOVED,this.mapTileRemoved.bind(this)),this.warpedMapList.addEventListener(k.IMAGEINFOLOADED,this.imageInfoLoaded.bind(this)),this.warpedMapList.addEventListener(k.WARPEDMAPADDED,this.warpedMapAdded.bind(this)),this.warpedMapList.addEventListener(k.WARPEDMAPREMOVED,this.warpedMapRemoved.bind(this)),this.warpedMapList.addEventListener(k.TRANSFORMATIONCHANGED,this.transformationChanged.bind(this)),this.warpedMapList.addEventListener(k.DISTORTIONCHANGED,this.distortionChanged.bind(this))}removeEventListeners(){this.tileCache.removeEventListener(k.MAPTILELOADED,this.mapTileLoaded.bind(this)),this.tileCache.removeEventListener(k.MAPTILEREMOVED,this.mapTileRemoved.bind(this)),this.warpedMapList.removeEventListener(k.IMAGEINFOLOADED,this.imageInfoLoaded.bind(this)),this.warpedMapList.removeEventListener(k.WARPEDMAPADDED,this.warpedMapAdded.bind(this)),this.warpedMapList.removeEventListener(k.WARPEDMAPREMOVED,this.warpedMapRemoved.bind(this)),this.warpedMapList.removeEventListener(k.TRANSFORMATIONCHANGED,this.transformationChanged.bind(this)),this.warpedMapList.removeEventListener(k.DISTORTIONCHANGED,this.distortionChanged.bind(this))}}var Yp=`#version 300 es
16
+
17
+ precision highp float;
18
+
19
+ uniform mat4 u_renderTransform;
20
+
21
+ uniform float u_animationProgress;
22
+
23
+ in vec2 a_resourceTrianglePoint;
24
+ in vec2 a_clipPreviousTrianglePoint;
25
+ in vec2 a_clipTrianglePoint;
26
+ in float a_previousTrianglePointDistortion;
27
+ in float a_trianglePointDistortion;
28
+ in float a_triangleIndex;
29
+
30
+ out vec2 v_resourceTrianglePoint;
31
+ out float v_trianglePointDistortion;
32
+ out float v_triangleIndex;
33
+
34
+ float cubicInOut(float t) {
35
+ return t < 0.5f ? 4.0f * t * t * t : 0.5f * pow(2.0f * t - 2.0f, 3.0f) + 1.0f;
36
+ }
37
+
38
+ void main() {
39
+
40
+ vec2 clipTrianglePoint = mix(a_clipPreviousTrianglePoint, a_clipTrianglePoint, cubicInOut(u_animationProgress));
41
+ float trianglePointDistortion = mix(a_previousTrianglePointDistortion, a_trianglePointDistortion, cubicInOut(u_animationProgress));
42
+
43
+
44
+
45
+
46
+
47
+ gl_Position = u_renderTransform * vec4(clipTrianglePoint, 0.0f, 1.0f);
48
+
49
+
50
+ v_resourceTrianglePoint = a_resourceTrianglePoint;
51
+ v_trianglePointDistortion = trianglePointDistortion;
52
+ v_triangleIndex = a_triangleIndex;
53
+ }`,Kp=`#version 300 es
54
+
55
+ precision highp float;
56
+ precision highp isampler2D;
57
+
58
+ #ifndef SPECTRAL
59
+ #define SPECTRAL
60
+
61
+ const int SPECTRAL_SIZE = 38;
62
+ const float SPECTRAL_GAMMA = 2.4;
63
+ const float SPECTRAL_EPSILON = 0.0001;
64
+
65
+ float spectral_uncompand(float x) {
66
+ return (x < 0.04045) ? x / 12.92 : pow((x + 0.055) / 1.055, SPECTRAL_GAMMA);
67
+ }
68
+
69
+ float spectral_compand(float x) {
70
+ return (x < 0.0031308) ? x * 12.92 : 1.055 * pow(x, 1.0 / SPECTRAL_GAMMA) - 0.055;
71
+ }
72
+
73
+ vec3 spectral_srgb_to_linear(vec3 srgb) {
74
+ return vec3(spectral_uncompand(srgb[0]), spectral_uncompand(srgb[1]), spectral_uncompand(srgb[2]));
75
+ }
76
+
77
+ vec3 spectral_linear_to_srgb(vec3 lrgb) {
78
+ return clamp(vec3(spectral_compand(lrgb[0]), spectral_compand(lrgb[1]), spectral_compand(lrgb[2])), 0.0, 1.0);
79
+ }
80
+
81
+ void spectral_upsampling(vec3 lrgb, out float w, out float c, out float m, out float y, out float r, out float g, out float b) {
82
+ w = min(lrgb.r, min(lrgb.g, lrgb.b));
83
+
84
+ lrgb -= w;
85
+
86
+ c = min(lrgb.g, lrgb.b);
87
+ m = min(lrgb.r, lrgb.b);
88
+ y = min(lrgb.r, lrgb.g);
89
+ r = min(max(0., lrgb.r - lrgb.b), max(0., lrgb.r - lrgb.g));
90
+ g = min(max(0., lrgb.g - lrgb.b), max(0., lrgb.g - lrgb.r));
91
+ b = min(max(0., lrgb.b - lrgb.g), max(0., lrgb.b - lrgb.r));
92
+ }
93
+
94
+ void spectral_linear_to_reflectance(vec3 lrgb, inout float R[SPECTRAL_SIZE]) {
95
+ float w, c, m, y, r, g, b;
96
+
97
+ spectral_upsampling(lrgb, w, c, m, y, r, g, b);
98
+
99
+ R[0] = max(SPECTRAL_EPSILON, w + c * 0.96853629 + m * 0.51567122 + y * 0.02055257 + r * 0.03147571 + g * 0.49108579 + b * 0.97901834);
100
+ R[1] = max(SPECTRAL_EPSILON, w + c * 0.96855103 + m * 0.54015520 + y * 0.02059936 + r * 0.03146636 + g * 0.46944057 + b * 0.97901649);
101
+ R[2] = max(SPECTRAL_EPSILON, w + c * 0.96859338 + m * 0.62645502 + y * 0.02062723 + r * 0.03140624 + g * 0.40165780 + b * 0.97901118);
102
+ R[3] = max(SPECTRAL_EPSILON, w + c * 0.96877345 + m * 0.75595012 + y * 0.02073387 + r * 0.03119611 + g * 0.24490420 + b * 0.97892146);
103
+ R[4] = max(SPECTRAL_EPSILON, w + c * 0.96942204 + m * 0.92826996 + y * 0.02114202 + r * 0.03053888 + g * 0.06826880 + b * 0.97858555);
104
+ R[5] = max(SPECTRAL_EPSILON, w + c * 0.97143709 + m * 0.97223624 + y * 0.02233154 + r * 0.02856855 + g * 0.02732883 + b * 0.97743705);
105
+ R[6] = max(SPECTRAL_EPSILON, w + c * 0.97541862 + m * 0.98616174 + y * 0.02556857 + r * 0.02459485 + g * 0.01360600 + b * 0.97428075);
106
+ R[7] = max(SPECTRAL_EPSILON, w + c * 0.98074186 + m * 0.98955255 + y * 0.03330189 + r * 0.01929520 + g * 0.01000187 + b * 0.96663223);
107
+ R[8] = max(SPECTRAL_EPSILON, w + c * 0.98580992 + m * 0.98676237 + y * 0.05185294 + r * 0.01423112 + g * 0.01284127 + b * 0.94822893);
108
+ R[9] = max(SPECTRAL_EPSILON, w + c * 0.98971194 + m * 0.97312575 + y * 0.10087639 + r * 0.01033111 + g * 0.02636635 + b * 0.89937713);
109
+ R[10] = max(SPECTRAL_EPSILON, w + c * 0.99238027 + m * 0.91944277 + y * 0.24000413 + r * 0.00765876 + g * 0.07058713 + b * 0.76070164);
110
+ R[11] = max(SPECTRAL_EPSILON, w + c * 0.99409844 + m * 0.32564851 + y * 0.53589066 + r * 0.00593693 + g * 0.70421692 + b * 0.46420440);
111
+ R[12] = max(SPECTRAL_EPSILON, w + c * 0.99517200 + m * 0.13820628 + y * 0.79874659 + r * 0.00485616 + g * 0.85473994 + b * 0.20123039);
112
+ R[13] = max(SPECTRAL_EPSILON, w + c * 0.99576545 + m * 0.05015143 + y * 0.91186529 + r * 0.00426186 + g * 0.95081565 + b * 0.08808402);
113
+ R[14] = max(SPECTRAL_EPSILON, w + c * 0.99593552 + m * 0.02912336 + y * 0.95399623 + r * 0.00409039 + g * 0.97170370 + b * 0.04592894);
114
+ R[15] = max(SPECTRAL_EPSILON, w + c * 0.99564041 + m * 0.02421691 + y * 0.97137099 + r * 0.00438375 + g * 0.97651888 + b * 0.02860373);
115
+ R[16] = max(SPECTRAL_EPSILON, w + c * 0.99464769 + m * 0.02660696 + y * 0.97939505 + r * 0.00537525 + g * 0.97429245 + b * 0.02060067);
116
+ R[17] = max(SPECTRAL_EPSILON, w + c * 0.99229579 + m * 0.03407586 + y * 0.98345207 + r * 0.00772962 + g * 0.97012917 + b * 0.01656701);
117
+ R[18] = max(SPECTRAL_EPSILON, w + c * 0.98638762 + m * 0.04835936 + y * 0.98553736 + r * 0.01366120 + g * 0.94258630 + b * 0.01451549);
118
+ R[19] = max(SPECTRAL_EPSILON, w + c * 0.96829712 + m * 0.00011720 + y * 0.98648905 + r * 0.03181352 + g * 0.99989207 + b * 0.01357964);
119
+ R[20] = max(SPECTRAL_EPSILON, w + c * 0.89228016 + m * 0.00008554 + y * 0.98674535 + r * 0.10791525 + g * 0.99989891 + b * 0.01331243);
120
+ R[21] = max(SPECTRAL_EPSILON, w + c * 0.53740239 + m * 0.85267882 + y * 0.98657555 + r * 0.46249516 + g * 0.13823139 + b * 0.01347661);
121
+ R[22] = max(SPECTRAL_EPSILON, w + c * 0.15360445 + m * 0.93188793 + y * 0.98611877 + r * 0.84604333 + g * 0.06968113 + b * 0.01387181);
122
+ R[23] = max(SPECTRAL_EPSILON, w + c * 0.05705719 + m * 0.94810268 + y * 0.98559942 + r * 0.94275572 + g * 0.05628787 + b * 0.01435472);
123
+ R[24] = max(SPECTRAL_EPSILON, w + c * 0.03126539 + m * 0.94200977 + y * 0.98507063 + r * 0.96860996 + g * 0.06111561 + b * 0.01479836);
124
+ R[25] = max(SPECTRAL_EPSILON, w + c * 0.02205445 + m * 0.91478045 + y * 0.98460039 + r * 0.97783966 + g * 0.08987709 + b * 0.01515250);
125
+ R[26] = max(SPECTRAL_EPSILON, w + c * 0.01802271 + m * 0.87065445 + y * 0.98425301 + r * 0.98187757 + g * 0.13656016 + b * 0.01540513);
126
+ R[27] = max(SPECTRAL_EPSILON, w + c * 0.01613460 + m * 0.78827548 + y * 0.98403909 + r * 0.98377315 + g * 0.22169624 + b * 0.01557233);
127
+ R[28] = max(SPECTRAL_EPSILON, w + c * 0.01520947 + m * 0.65738359 + y * 0.98388535 + r * 0.98470202 + g * 0.32176956 + b * 0.01565710);
128
+ R[29] = max(SPECTRAL_EPSILON, w + c * 0.01475977 + m * 0.59909403 + y * 0.98376116 + r * 0.98515481 + g * 0.36157329 + b * 0.01571025);
129
+ R[30] = max(SPECTRAL_EPSILON, w + c * 0.01454263 + m * 0.56817268 + y * 0.98368246 + r * 0.98537114 + g * 0.48361920 + b * 0.01571916);
130
+ R[31] = max(SPECTRAL_EPSILON, w + c * 0.01444459 + m * 0.54031997 + y * 0.98365023 + r * 0.98546685 + g * 0.46488579 + b * 0.01572133);
131
+ R[32] = max(SPECTRAL_EPSILON, w + c * 0.01439897 + m * 0.52110241 + y * 0.98361309 + r * 0.98550011 + g * 0.47440306 + b * 0.01572502);
132
+ R[33] = max(SPECTRAL_EPSILON, w + c * 0.01437620 + m * 0.51041094 + y * 0.98357259 + r * 0.98551031 + g * 0.48576990 + b * 0.01571717);
133
+ R[34] = max(SPECTRAL_EPSILON, w + c * 0.01436343 + m * 0.50526577 + y * 0.98353856 + r * 0.98550741 + g * 0.49267971 + b * 0.01571905);
134
+ R[35] = max(SPECTRAL_EPSILON, w + c * 0.01435687 + m * 0.50255080 + y * 0.98351247 + r * 0.98551323 + g * 0.49625685 + b * 0.01571059);
135
+ R[36] = max(SPECTRAL_EPSILON, w + c * 0.01435370 + m * 0.50126452 + y * 0.98350101 + r * 0.98551563 + g * 0.49807754 + b * 0.01569728);
136
+ R[37] = max(SPECTRAL_EPSILON, w + c * 0.01435408 + m * 0.50083021 + y * 0.98350852 + r * 0.98551547 + g * 0.49889859 + b * 0.01570020);
137
+ }
138
+
139
+ vec3 spectral_xyz_to_srgb(vec3 xyz) {
140
+ mat3 XYZ_RGB;
141
+
142
+ XYZ_RGB[0] = vec3( 3.24306333, -1.53837619, -0.49893282);
143
+ XYZ_RGB[1] = vec3(-0.96896309, 1.87542451, 0.04154303);
144
+ XYZ_RGB[2] = vec3( 0.05568392, -0.20417438, 1.05799454);
145
+
146
+ float r = dot(XYZ_RGB[0], xyz);
147
+ float g = dot(XYZ_RGB[1], xyz);
148
+ float b = dot(XYZ_RGB[2], xyz);
149
+
150
+ return spectral_linear_to_srgb(vec3(r, g, b));
151
+ }
152
+
153
+ vec3 spectral_reflectance_to_xyz(float R[SPECTRAL_SIZE]) {
154
+ vec3 xyz = vec3(0.0);
155
+
156
+ xyz += R[0] * vec3(0.00006469, 0.00000184, 0.00030502);
157
+ xyz += R[1] * vec3(0.00021941, 0.00000621, 0.00103681);
158
+ xyz += R[2] * vec3(0.00112057, 0.00003101, 0.00531314);
159
+ xyz += R[3] * vec3(0.00376661, 0.00010475, 0.01795439);
160
+ xyz += R[4] * vec3(0.01188055, 0.00035364, 0.05707758);
161
+ xyz += R[5] * vec3(0.02328644, 0.00095147, 0.11365162);
162
+ xyz += R[6] * vec3(0.03455942, 0.00228226, 0.17335873);
163
+ xyz += R[7] * vec3(0.03722379, 0.00420733, 0.19620658);
164
+ xyz += R[8] * vec3(0.03241838, 0.00668880, 0.18608237);
165
+ xyz += R[9] * vec3(0.02123321, 0.00988840, 0.13995048);
166
+ xyz += R[10] * vec3(0.01049099, 0.01524945, 0.08917453);
167
+ xyz += R[11] * vec3(0.00329584, 0.02141831, 0.04789621);
168
+ xyz += R[12] * vec3(0.00050704, 0.03342293, 0.02814563);
169
+ xyz += R[13] * vec3(0.00094867, 0.05131001, 0.01613766);
170
+ xyz += R[14] * vec3(0.00627372, 0.07040208, 0.00775910);
171
+ xyz += R[15] * vec3(0.01686462, 0.08783871, 0.00429615);
172
+ xyz += R[16] * vec3(0.02868965, 0.09424905, 0.00200551);
173
+ xyz += R[17] * vec3(0.04267481, 0.09795667, 0.00086147);
174
+ xyz += R[18] * vec3(0.05625475, 0.09415219, 0.00036904);
175
+ xyz += R[19] * vec3(0.06947040, 0.08678102, 0.00019143);
176
+ xyz += R[20] * vec3(0.08305315, 0.07885653, 0.00014956);
177
+ xyz += R[21] * vec3(0.08612610, 0.06352670, 0.00009231);
178
+ xyz += R[22] * vec3(0.09046614, 0.05374142, 0.00006813);
179
+ xyz += R[23] * vec3(0.08500387, 0.04264606, 0.00002883);
180
+ xyz += R[24] * vec3(0.07090667, 0.03161735, 0.00001577);
181
+ xyz += R[25] * vec3(0.05062889, 0.02088521, 0.00000394);
182
+ xyz += R[26] * vec3(0.03547396, 0.01386011, 0.00000158);
183
+ xyz += R[27] * vec3(0.02146821, 0.00810264, 0.00000000);
184
+ xyz += R[28] * vec3(0.01251646, 0.00463010, 0.00000000);
185
+ xyz += R[29] * vec3(0.00680458, 0.00249138, 0.00000000);
186
+ xyz += R[30] * vec3(0.00346457, 0.00125930, 0.00000000);
187
+ xyz += R[31] * vec3(0.00149761, 0.00054165, 0.00000000);
188
+ xyz += R[32] * vec3(0.00076970, 0.00027795, 0.00000000);
189
+ xyz += R[33] * vec3(0.00040737, 0.00014711, 0.00000000);
190
+ xyz += R[34] * vec3(0.00016901, 0.00006103, 0.00000000);
191
+ xyz += R[35] * vec3(0.00009522, 0.00003439, 0.00000000);
192
+ xyz += R[36] * vec3(0.00004903, 0.00001771, 0.00000000);
193
+ xyz += R[37] * vec3(0.00002000, 0.00000722, 0.00000000);
194
+
195
+ return xyz;
196
+ }
197
+
198
+ float spectral_linear_to_concentration(float l1, float l2, float t) {
199
+ float t1 = l1 * pow(1.0 - t, 2.0);
200
+ float t2 = l2 * pow(t, 2.0);
201
+
202
+ return t2 / (t1 + t2);
203
+ }
204
+
205
+ vec3 spectral_mix(vec3 color1, vec3 color2, float t) {
206
+ vec3 lrgb1 = spectral_srgb_to_linear(color1);
207
+ vec3 lrgb2 = spectral_srgb_to_linear(color2);
208
+
209
+ float R1[SPECTRAL_SIZE];
210
+ float R2[SPECTRAL_SIZE];
211
+
212
+ spectral_linear_to_reflectance(lrgb1, R1);
213
+ spectral_linear_to_reflectance(lrgb2, R2);
214
+
215
+ float l1 = spectral_reflectance_to_xyz(R1)[1];
216
+ float l2 = spectral_reflectance_to_xyz(R2)[1];
217
+
218
+ t = spectral_linear_to_concentration(l1, l2, t);
219
+
220
+ float R[SPECTRAL_SIZE];
221
+
222
+ for (int i = 0; i < SPECTRAL_SIZE; i++) {
223
+ float KS = (1.0 - t) * (pow(1.0 - R1[i], 2.0) / (2.0 * R1[i])) + t * (pow(1.0 - R2[i], 2.0) / (2.0 * R2[i]));
224
+ float KM = 1.0 + KS - sqrt(pow(KS, 2.0) + 2.0 * KS);
225
+
226
+
227
+
228
+
229
+ R[i] = KM;
230
+ }
231
+
232
+ return spectral_xyz_to_srgb(spectral_reflectance_to_xyz(R));
233
+ }
234
+
235
+ vec4 spectral_mix(vec4 color1, vec4 color2, float t) {
236
+ return vec4(spectral_mix(color1.rgb, color2.rgb, t), mix(color1.a, color2.a, t));
237
+ }
238
+
239
+ #endif
240
+
241
+ uniform bool u_removeColor;
242
+ uniform vec3 u_removeColorOptionsColor;
243
+ uniform float u_removeColorOptionsThreshold;
244
+ uniform float u_removeColorOptionsHardness;
245
+
246
+ uniform bool u_colorize;
247
+ uniform vec3 u_colorizeOptionsColor;
248
+
249
+ uniform bool u_grid;
250
+
251
+ uniform float u_opacity;
252
+ uniform float u_saturation;
253
+
254
+ uniform bool u_distortion;
255
+ uniform int u_distortionOptionsdistortionMeasure;
256
+
257
+ uniform int u_bestScaleFactor;
258
+
259
+ uniform sampler2D u_packedTilesTexture;
260
+ uniform isampler2D u_packedTilesPositionsTexture;
261
+ uniform isampler2D u_packedTilesResourcePositionsAndDimensionsTexture;
262
+ uniform isampler2D u_packedTilesScaleFactorsTexture;
263
+
264
+ in vec2 v_resourceTrianglePoint;
265
+ in float v_triangleIndex;
266
+ in float v_trianglePointDistortion;
267
+
268
+ out vec4 color;
269
+
270
+ vec4 rgbToVec4(int r, int g, int b) {
271
+ return vec4(float(r) / 255.0f, float(g) / 255.0f, float(b) / 255.0f, 1.0f);
272
+ }
273
+
274
+ void main() {
275
+
276
+
277
+
278
+ vec4 colorTransparent = vec4(0.0f, 0.0f, 0.0f, 0.0f);
279
+ vec4 colorWhite = vec4(1.0f, 1.0f, 1.0f, 1.0f);
280
+ vec4 colorBlack = vec4(0.0f, 0.0f, 0.0f, 1.0f);
281
+
282
+ vec4 colorGreen300 = vec4(0.5254f, 0.9372f, 0.6745f, 1.0f);
283
+ vec4 colorPurple300 = vec4(0.8470f, 0.7058f, 0.9960f, 1.0f);
284
+ vec4 colorRed300 = vec4(0.9882f, 0.6470f, 0.6470f, 1.0f);
285
+ vec4 colorYellow300 = vec4(0.9921f, 0.8784f, 0.2784f, 1.0f);
286
+ vec4 colorOrange300 = vec4(0.9921f, 0.7294f, 0.4549f, 1.0f);
287
+ vec4 colorPink300 = vec4(0.9764f, 0.6588f, 0.8313f, 1.0f);
288
+ vec4 colorBlue300 = vec4(0.5764f, 0.7725f, 0.9921f, 1.0f);
289
+ vec4 colorGrey300 = vec4(0.8196f, 0.8352f, 0.8588f, 1.0f);
290
+
291
+ vec4 colorGreen500 = vec4(0.1333f, 0.7725f, 0.3686f, 1.0f);
292
+ vec4 colorPurple500 = vec4(0.6588f, 0.3333f, 0.9686f, 1.0f);
293
+ vec4 colorRed500 = vec4(0.9372f, 0.2666f, 0.2666f, 1.0f);
294
+ vec4 colorYellow500 = vec4(0.9176f, 0.7019f, 0.0313f, 1.0f);
295
+ vec4 colorOrange500 = vec4(0.9764f, 0.4509f, 0.0862f, 1.0f);
296
+ vec4 colorPink500 = vec4(0.9254f, 0.2823f, 0.6f, 1.0f);
297
+ vec4 colorBlue500 = vec4(0.2313f, 0.5098f, 0.9647f, 1.0f);
298
+ vec4 colorGrey500 = vec4(0.4196f, 0.4470f, 0.5019f, 1.0f);
299
+
300
+ float resourceTrianglePointX = v_resourceTrianglePoint.x;
301
+ float resourceTrianglePointY = v_resourceTrianglePoint.y;
302
+
303
+
304
+ int packedTilesCount = textureSize(u_packedTilesPositionsTexture, 0).y;
305
+ ivec2 packedTilesTextureSize = textureSize(u_packedTilesTexture, 0);
306
+
307
+
308
+ int smallestScaleFactorDiff = 256 * 256;
309
+ int bestScaleFactor = 0;
310
+
311
+
312
+ vec2 packedTilesTexturePoint = vec2(0.0f, 0.0f);
313
+
314
+
315
+ color = colorTransparent;
316
+ bool found = false;
317
+
318
+
319
+ for(int index = 0; index < packedTilesCount; index += 1) {
320
+
321
+
322
+ ivec2 packedTilePosition = texelFetch(u_packedTilesPositionsTexture, ivec2(0, index), 0).rg;
323
+ ivec4 packedTileResourcePositionAndDimension = texelFetch(u_packedTilesResourcePositionsAndDimensionsTexture, ivec2(0, index), 0);
324
+ int packedTileScaleFactor = texelFetch(u_packedTilesScaleFactorsTexture, ivec2(0, index), 0).r;
325
+
326
+ float packedTilePositionX = float(packedTilePosition.r);
327
+ float packedTilePositionY = float(packedTilePosition.g);
328
+
329
+ float packedTileResourcePositionX = float(packedTileResourcePositionAndDimension.r);
330
+ float packedTileResourcePositionY = float(packedTileResourcePositionAndDimension.g);
331
+
332
+ float packedTileDimensionWidth = float(packedTileResourcePositionAndDimension.b);
333
+ float packedTileDimensionHeight = float(packedTileResourcePositionAndDimension.a);
334
+
335
+
336
+
337
+
338
+
339
+ if(resourceTrianglePointX >= packedTileResourcePositionX &&
340
+ resourceTrianglePointX < packedTileResourcePositionX + packedTileDimensionWidth &&
341
+ resourceTrianglePointY >= packedTileResourcePositionY &&
342
+ resourceTrianglePointY < packedTileResourcePositionY + packedTileDimensionHeight) {
343
+ found = true;
344
+
345
+ int scaleFactorDiff = abs(u_bestScaleFactor - packedTileScaleFactor);
346
+
347
+ if(scaleFactorDiff < smallestScaleFactorDiff || bestScaleFactor == 0) {
348
+
349
+ smallestScaleFactorDiff = scaleFactorDiff;
350
+ bestScaleFactor = packedTileScaleFactor;
351
+
352
+ float packedTilePointX = (resourceTrianglePointX - packedTileResourcePositionX) / float(bestScaleFactor);
353
+ float packedTilePointY = (resourceTrianglePointY - packedTileResourcePositionY) / float(bestScaleFactor);
354
+
355
+ float packedTilesPointX = packedTilePositionX + packedTilePointX;
356
+ float packedTilesPointY = packedTilePositionY + packedTilePointY;
357
+
358
+ float packedTilesTexturePointX = packedTilesPointX / float(packedTilesTextureSize.x);
359
+ float packedTilesTexturePointY = packedTilesPointY / float(packedTilesTextureSize.y);
360
+
361
+ packedTilesTexturePoint = vec2(packedTilesTexturePointX, packedTilesTexturePointY);
362
+ }
363
+ }
364
+ }
365
+
366
+ if(found == true) {
367
+
368
+ color = texture(u_packedTilesTexture, packedTilesTexturePoint);
369
+
370
+
371
+ if(u_removeColorOptionsThreshold > 0.0f) {
372
+ vec3 backgroundColorDiff = color.rgb - u_removeColorOptionsColor.rgb;
373
+ float backgroundColorDistance = length(backgroundColorDiff);
374
+ if(u_removeColor && backgroundColorDistance < u_removeColorOptionsThreshold) {
375
+ float amount = smoothstep(u_removeColorOptionsThreshold - u_removeColorOptionsThreshold * (1.0f - u_removeColorOptionsHardness), u_removeColorOptionsThreshold, backgroundColorDistance);
376
+ color = vec4(color.rgb * amount, amount);
377
+ }
378
+ }
379
+
380
+
381
+ float gray = 0.21f * color.r + 0.71f * color.g + 0.07f * color.b;
382
+ color = vec4(color.rgb * (u_saturation) + (gray * (1.0f - u_saturation)), color.a);
383
+
384
+
385
+ if(u_colorize) {
386
+ color = vec4((u_colorizeOptionsColor + color.rgb) * color.a, color.a);
387
+ }
388
+
389
+
390
+ color = vec4(color.rgb * u_opacity, color.a * u_opacity);
391
+
392
+
393
+
394
+ if(u_distortion) {
395
+
396
+
397
+
398
+ float trianglePointDistortion = v_trianglePointDistortion;
399
+
400
+
401
+ trianglePointDistortion = floor(trianglePointDistortion * 10.0f) / 10.0f;
402
+
403
+ switch(u_distortionOptionsdistortionMeasure) {
404
+ case 0:
405
+ if(trianglePointDistortion > 0.0f) {
406
+ color = spectral_mix(color, colorRed500, trianglePointDistortion);
407
+ } else {
408
+ color = spectral_mix(color, colorBlue500, abs(trianglePointDistortion));
409
+ }
410
+ break;
411
+ case 1:
412
+ color = spectral_mix(color, colorGreen500, trianglePointDistortion);
413
+ break;
414
+ case 2:
415
+ color = spectral_mix(color, colorYellow500, trianglePointDistortion);
416
+ break;
417
+ case 3:
418
+ color = trianglePointDistortion == -1.0f ? colorRed300 : color;
419
+ break;
420
+ default:
421
+ color = color;
422
+ }
423
+ }
424
+
425
+
426
+
427
+ if(false) {
428
+ color = vec4(abs(sin(v_triangleIndex)), abs(sin(v_triangleIndex + 1.0f)), abs(sin(v_triangleIndex + 2.0f)), 1);
429
+ }
430
+
431
+
432
+ if(u_grid) {
433
+ float gridSize = 20.0f * float(u_bestScaleFactor);
434
+ float gridWidth = 2.0f * float(u_bestScaleFactor);
435
+ if(mod(float(resourceTrianglePointX) + gridWidth / 2.0f, gridSize) < gridWidth || mod(float(resourceTrianglePointY) + gridWidth / 2.0f, gridSize) < gridWidth) {
436
+ color = colorBlack;
437
+ }
438
+ }
439
+ }
440
+ }`;const Jp=500,Qp={leading:!0,trailing:!0},tf=50,ef={leading:!0,trailing:!0},Li=1,Oi=1,rf=0,sf=.7,nf=5,cn=750;class of extends Hp{constructor(t,r){const s=en(t,t.VERTEX_SHADER,Yp),n=en(t,t.FRAGMENT_SHADER,Kp),o=Gd(t,s,n);super(Ms.createFactory(),Zd(t,o),r);M(this,"gl");M(this,"program");M(this,"previousSignificantViewport");M(this,"opacity",Li);M(this,"saturation",Oi);M(this,"renderOptions",{});M(this,"invertedRenderTransform");M(this,"lastAnimationFrameRequestId");M(this,"animating",!1);M(this,"transformationTransitionStart");M(this,"animationProgress",1);M(this,"throttledPrepareRenderInternal");M(this,"throttledChanged");this.gl=t,this.program=o,t.deleteShader(s),t.deleteShader(n),t.disable(t.DEPTH_TEST),this.invertedRenderTransform=ia(),this.addEventListeners(),this.throttledPrepareRenderInternal=Hi(this.prepareRenderInternal.bind(this),Jp,Qp),this.throttledChanged=Hi(this.changed.bind(this),tf,ef)}getOpacity(){return this.opacity}setOpacity(t){this.opacity=t}resetOpacity(){this.opacity=Li}getMapOpacity(t){const r=this.warpedMapList.getWarpedMap(t);if(r)return r.opacity}setMapOpacity(t,r){const s=this.warpedMapList.getWarpedMap(t);s&&(s.opacity=Math.min(Math.max(r,0),1))}resetMapOpacity(t){const r=this.warpedMapList.getWarpedMap(t);r&&(r.opacity=Li)}getRemoveColorOptions(){return this.renderOptions.removeColorOptions}setRemoveColorOptions(t){this.renderOptions.removeColorOptions=t}resetRemoveColorOptions(){this.renderOptions.removeColorOptions=void 0}getMapRemoveColorOptions(t){const r=this.warpedMapList.getWarpedMap(t);if(r)return r.renderOptions.removeColorOptions}setMapRemoveColorOptions(t,r){const s=this.warpedMapList.getWarpedMap(t);s&&(s.renderOptions.removeColorOptions=r)}resetMapRemoveColorOptions(t){const r=this.warpedMapList.getWarpedMap(t);r&&(r.renderOptions.removeColorOptions=void 0)}getColorizeOptions(){return this.renderOptions.colorizeOptions}setColorizeOptions(t){this.renderOptions.colorizeOptions=t}resetColorizeOptions(){this.renderOptions.colorizeOptions=void 0}getMapColorizeOptions(t){const r=this.warpedMapList.getWarpedMap(t);if(r)return r.renderOptions.colorizeOptions}setMapColorizeOptions(t,r){const s=this.warpedMapList.getWarpedMap(t);s&&(s.renderOptions.colorizeOptions=r)}resetMapColorizeOptions(t){const r=this.warpedMapList.getWarpedMap(t);r&&(r.renderOptions.colorizeOptions=void 0)}getGridOptions(){return this.renderOptions.gridOptions}setGridOptions(t){this.renderOptions.gridOptions=t}resetGridOptions(){this.renderOptions.gridOptions=void 0}getMapGridOptions(t){const r=this.warpedMapList.getWarpedMap(t);if(r)return r.renderOptions.gridOptions}setMapGridOptions(t,r){const s=this.warpedMapList.getWarpedMap(t);s&&(s.renderOptions.gridOptions=r)}resetMapGridOptions(t){const r=this.warpedMapList.getWarpedMap(t);r&&(r.renderOptions.gridOptions=void 0)}getSaturation(){return this.saturation}setSaturation(t){this.saturation=t}resetSaturation(){this.saturation=Oi}getMapSaturation(t){const r=this.warpedMapList.getWarpedMap(t);if(r)return r.saturation}setMapSaturation(t,r){const s=this.warpedMapList.getWarpedMap(t);s&&(s.saturation=r)}resetMapSaturation(t){const r=this.warpedMapList.getWarpedMap(t);r&&(r.saturation=Oi)}render(t){this.viewport=t,this.loadMissingImageInfosInViewport(),this.someImageInfosInViewport()&&this.throttledPrepareRenderInternal(),this.renderInternal()}clear(){this.warpedMapList.clear(),this.mapsInViewport=new Set,this.gl.clear(this.gl.DEPTH_BUFFER_BIT|this.gl.COLOR_BUFFER_BIT),this.tileCache.clear()}dispose(){for(const t of this.warpedMapList.getWarpedMaps())this.removeEventListenersFromWebGL2WarpedMap(t),t.dispose();this.tileCache.clear(),this.tileCache.dispose(),this.removeEventListeners(),this.gl.deleteProgram(this.program)}prepareRenderInternal(){this.updateRequestedTiles(),this.updateVertexBuffers()}shouldUpdateRequestedTiles(){if(!this.viewport||this.animating)return!1;if(this.previousSignificantViewport){const t=[];for(let s=0;s<4;s++)t.push(bt(this.previousSignificantViewport.projectedGeoRectangle[s],this.viewport.projectedGeoRectangle[s])/this.viewport.projectedGeoPerViewportScale);const r=Math.max(...t);return r===0?!0:r>nf?(this.previousSignificantViewport=this.viewport,!0):!1}else return this.previousSignificantViewport=this.viewport,!0}updateVertexBuffers(){if(this.viewport){this.invertedRenderTransform=na(this.viewport.projectedGeoToClipTransform);for(const t of this.mapsInViewport){const r=this.warpedMapList.getWarpedMap(t);if(!r)break;r.updateVertexBuffers(this.viewport.projectedGeoToClipTransform)}}}renderInternal(){if(!this.viewport)return;const t=sa(this.viewport.projectedGeoToClipTransform,this.invertedRenderTransform),r=this.gl;r.viewport(0,0,r.canvas.width,r.canvas.height),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.useProgram(this.program);const s=r.getUniformLocation(this.program,"u_renderTransform");r.uniformMatrix4fv(s,!1,aa(t));const n=r.getUniformLocation(this.program,"u_animationProgress");r.uniform1f(n,this.animationProgress);for(const o of this.mapsInViewport){const a=this.warpedMapList.getWarpedMap(o);if(!a)continue;this.setRenderOptionsUniforms(this.renderOptions,a.renderOptions);const h=r.getUniformLocation(this.program,"u_opacity");r.uniform1f(h,this.opacity*a.opacity);const c=r.getUniformLocation(this.program,"u_saturation");r.uniform1f(c,this.saturation*a.saturation);const l=r.getUniformLocation(this.program,"u_distortion");if(r.uniform1f(l,a.distortionMeasure?1:0),a.distortionMeasure){const f=r.getUniformLocation(this.program,"u_distortionOptionsdistortionMeasure");r.uniform1i(f,ao.indexOf(a.distortionMeasure))}const u=r.getUniformLocation(this.program,"u_bestScaleFactor"),m=a.bestScaleFactor;r.uniform1i(u,m);const g=r.getUniformLocation(this.program,"u_packedTilesTexture");r.uniform1i(g,0),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a.packedTilesTexture);const y=r.getUniformLocation(this.program,"u_packedTilesPositionsTexture");r.uniform1i(y,1),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,a.packedTilesPositionsTexture);const _=r.getUniformLocation(this.program,"u_packedTilesResourcePositionsAndDimensionsTexture");r.uniform1i(_,2),r.activeTexture(r.TEXTURE2),r.bindTexture(r.TEXTURE_2D,a.packedTilesResourcePositionsAndDimensionsTexture);const I=r.getUniformLocation(this.program,"u_packedTilesScaleFactorsTexture");r.uniform1i(I,3),r.activeTexture(r.TEXTURE3),r.bindTexture(r.TEXTURE_2D,a.packedTilesScaleFactorsTexture);const w=a.vao,R=a.resourceTrianglePoints.length,d=this.gl.TRIANGLES;r.bindVertexArray(w),r.drawArrays(d,0,R)}}setRenderOptionsUniforms(t,r){var m,g,y,_,I,w,R,d,f,x,S;const s=this.gl,n={removeColorOptions:{color:((m=r.removeColorOptions)==null?void 0:m.color)||((g=t.removeColorOptions)==null?void 0:g.color),hardness:Rs((y=r.removeColorOptions)==null?void 0:y.hardness,(_=t.removeColorOptions)==null?void 0:_.hardness),threshold:Rs((I=r.removeColorOptions)==null?void 0:I.threshold,(w=t.removeColorOptions)==null?void 0:w.threshold)},colorizeOptions:{...t.colorizeOptions,...r.colorizeOptions},gridOptions:{...t.gridOptions,...r.gridOptions}},o=(R=n.removeColorOptions)==null?void 0:R.color,a=s.getUniformLocation(this.program,"u_removeColor");if(s.uniform1f(a,o?1:0),o){const T=s.getUniformLocation(this.program,"u_removeColorOptionsColor");s.uniform3fv(T,o);const E=s.getUniformLocation(this.program,"u_removeColorOptionsThreshold");s.uniform1f(E,((d=n.removeColorOptions)==null?void 0:d.threshold)||rf);const p=s.getUniformLocation(this.program,"u_removeColorOptionsHardness");s.uniform1f(p,((f=n.removeColorOptions)==null?void 0:f.hardness)||sf)}const h=(x=n.colorizeOptions)==null?void 0:x.color,c=s.getUniformLocation(this.program,"u_colorize");if(s.uniform1f(c,h?1:0),h){const T=s.getUniformLocation(this.program,"u_colorizeOptionsColor");s.uniform3fv(T,h)}const l=(S=n.gridOptions)==null?void 0:S.enabled,u=s.getUniformLocation(this.program,"u_grid");s.uniform1f(u,l?1:0)}startTransformationTransition(){this.lastAnimationFrameRequestId!==void 0&&cancelAnimationFrame(this.lastAnimationFrameRequestId),this.animating=!0,this.transformationTransitionStart=void 0,this.lastAnimationFrameRequestId=requestAnimationFrame(this.transformationTransitionFrame.bind(this))}transformationTransitionFrame(t){if(this.transformationTransitionStart||(this.transformationTransitionStart=t),t-this.transformationTransitionStart<cn)this.animationProgress=(t-this.transformationTransitionStart)/cn,this.renderInternal(),this.lastAnimationFrameRequestId=requestAnimationFrame(this.transformationTransitionFrame.bind(this));else{for(const r of this.warpedMapList.getWarpedMaps())r.resetTrianglePoints();this.updateVertexBuffers(),this.animating=!1,this.animationProgress=0,this.transformationTransitionStart=void 0}}changed(){this.dispatchEvent(new Z(k.CHANGED))}imageInfoLoaded(t){t instanceof Z&&this.dispatchEvent(new Z(k.IMAGEINFOLOADED))}mapTileLoaded(t){if(t instanceof Z){const{mapId:r,tileUrl:s}=t.data,n=this.tileCache.getCacheableTile(s);if(!n||!n.isCachedTile())return;const o=this.warpedMapList.getWarpedMap(r);if(!o)return;o.addCachedTileAndUpdateTextures(n)}}mapTileRemoved(t){if(t instanceof Z){const{mapId:r,tileUrl:s}=t.data,n=this.warpedMapList.getWarpedMap(r);if(!n)return;n.removeCachedTileAndUpdateTextures(s)}}warpedMapAdded(t){if(t instanceof Z){const r=t.data,s=this.warpedMapList.getWarpedMap(r);s&&this.addEventListenersToWebGL2WarpedMap(s)}}transformationChanged(t){if(t instanceof Z){const r=t.data;for(const s of this.warpedMapList.getWarpedMaps(r))this.animating&&s.mixTrianglePoints(this.animationProgress),s.updateProjectedGeoTrianglePoints(!1);this.updateVertexBuffers(),this.startTransformationTransition()}}distortionChanged(t){if(t instanceof Z){const r=t.data;for(const s of this.warpedMapList.getWarpedMaps(r))this.animating&&s.mixTrianglePoints(this.animationProgress),s.updateTrianglePointsDistortion(!1);this.updateVertexBuffers(),this.startTransformationTransition()}}addEventListenersToWebGL2WarpedMap(t){t.addEventListener(k.TEXTURESUPDATED,this.throttledChanged.bind(this))}removeEventListenersFromWebGL2WarpedMap(t){t.removeEventListener(k.TEXTURESUPDATED,this.throttledChanged.bind(this))}}const af="Renderer not defined. Add the layer to a map before calling this function.";function z(i){if(!i)throw new Error(af)}class hf{constructor(e,t){M(this,"id","warped-map-layer");M(this,"type","custom");M(this,"renderingMode","2d");M(this,"map");M(this,"renderer");M(this,"options");e&&(this.id=e),this.options=t}onAdd(e,t){this.map=e,this.renderer=new of(t,this.options),this.addEventListeners()}onRemove(){this.renderer&&(this.renderer.dispose(),this.removeEventListeners())}async addGeoreferenceAnnotation(e){var r;z(this.renderer);const t=await this.renderer.warpedMapList.addGeoreferenceAnnotation(e);return(r=this.map)==null||r.triggerRepaint(),t}async removeGeoreferenceAnnotation(e){var r;z(this.renderer);const t=await this.renderer.warpedMapList.removeGeoreferenceAnnotation(e);return(r=this.map)==null||r.triggerRepaint(),t}async addGeoreferenceAnnotationByUrl(e){const t=await fetch(e).then(r=>r.json());return this.addGeoreferenceAnnotation(t)}async removeGeoreferenceAnnotationByUrl(e){const t=await fetch(e).then(r=>r.json());return this.removeGeoreferenceAnnotation(t)}async addGeoreferencedMap(e){var r;z(this.renderer);const t=this.renderer.warpedMapList.addGeoreferencedMap(e);return(r=this.map)==null||r.triggerRepaint(),t}async removeGeoreferencedMap(e){var r;z(this.renderer);const t=this.renderer.warpedMapList.removeGeoreferencedMap(e);return(r=this.map)==null||r.triggerRepaint(),t}getWarpedMapList(){return z(this.renderer),this.renderer.warpedMapList}getWarpedMap(e){return z(this.renderer),this.renderer.warpedMapList.getWarpedMap(e)}showMap(e){var t;z(this.renderer),this.renderer.warpedMapList.showMaps([e]),(t=this.map)==null||t.triggerRepaint()}showMaps(e){var t;z(this.renderer),this.renderer.warpedMapList.showMaps(e),(t=this.map)==null||t.triggerRepaint()}hideMap(e){var t;z(this.renderer),this.renderer.warpedMapList.hideMaps([e]),(t=this.map)==null||t.triggerRepaint()}hideMaps(e){var t;z(this.renderer),this.renderer.warpedMapList.hideMaps(e),(t=this.map)==null||t.triggerRepaint()}isMapVisible(e){var t;return z(this.renderer),(t=this.renderer.warpedMapList.getWarpedMap(e))==null?void 0:t.visible}setMapResourceMask(e,t){var r;z(this.renderer),this.renderer.warpedMapList.setMapResourceMask(e,t),(r=this.map)==null||r.triggerRepaint()}setMapsTransformationType(e,t){var r;z(this.renderer),this.renderer.warpedMapList.setMapsTransformationType(e,t),(r=this.map)==null||r.triggerRepaint()}setMapsDistortionMeasure(e,t){var r;z(this.renderer),this.renderer.warpedMapList.setMapsDistortionMeasure(e,t),(r=this.map)==null||r.triggerRepaint()}getBounds(){z(this.renderer);const e=this.renderer.warpedMapList.getBbox();if(e)return[[e[0],e[1]],[e[2],e[3]]]}bringMapsToFront(e){var t;z(this.renderer),this.renderer.warpedMapList.bringMapsToFront(e),(t=this.map)==null||t.triggerRepaint()}sendMapsToBack(e){var t;z(this.renderer),this.renderer.warpedMapList.sendMapsToBack(e),(t=this.map)==null||t.triggerRepaint()}bringMapsForward(e){var t;z(this.renderer),this.renderer.warpedMapList.bringMapsForward(e),(t=this.map)==null||t.triggerRepaint()}sendMapsBackward(e){var t;z(this.renderer),this.renderer.warpedMapList.sendMapsBackward(e),(t=this.map)==null||t.triggerRepaint()}getMapZIndex(e){return z(this.renderer),this.renderer.warpedMapList.getMapZIndex(e)}setImageInformations(e){z(this.renderer),this.renderer.warpedMapList.setImageInformations(e)}getOpacity(){return z(this.renderer),this.renderer.getOpacity()}setOpacity(e){var t;z(this.renderer),this.renderer.setOpacity(e),(t=this.map)==null||t.triggerRepaint()}resetOpacity(){var e;z(this.renderer),this.renderer.resetOpacity(),(e=this.map)==null||e.triggerRepaint()}getMapOpacity(e){return z(this.renderer),this.renderer.getMapOpacity(e)}setMapOpacity(e,t){var r;z(this.renderer),this.renderer.setMapOpacity(e,t),(r=this.map)==null||r.triggerRepaint()}resetMapOpacity(e){var t;z(this.renderer),this.renderer.resetMapOpacity(e),(t=this.map)==null||t.triggerRepaint()}setSaturation(e){var t;z(this.renderer),this.renderer.setSaturation(e),(t=this.map)==null||t.triggerRepaint()}resetSaturation(){var e;z(this.renderer),this.renderer.resetSaturation(),(e=this.map)==null||e.triggerRepaint()}setMapSaturation(e,t){var r;z(this.renderer),this.renderer.setMapSaturation(e,t),(r=this.map)==null||r.triggerRepaint()}resetMapSaturation(e){var t;z(this.renderer),this.renderer.resetMapSaturation(e),(t=this.map)==null||t.triggerRepaint()}setRemoveColor(e){var r;z(this.renderer);const t=e.hexColor?wr(e.hexColor):void 0;this.renderer.setRemoveColorOptions({color:t,threshold:e.threshold,hardness:e.hardness}),(r=this.map)==null||r.triggerRepaint()}resetRemoveColor(){var e;z(this.renderer),this.renderer.resetRemoveColorOptions(),(e=this.map)==null||e.triggerRepaint()}setMapRemoveColor(e,t){var s;z(this.renderer);const r=t.hexColor?wr(t.hexColor):void 0;this.renderer.setMapRemoveColorOptions(e,{color:r,threshold:t.threshold,hardness:t.hardness}),(s=this.map)==null||s.triggerRepaint()}resetMapRemoveColor(e){z(this.renderer),this.renderer.resetMapRemoveColorOptions(e)}setColorize(e){var r;z(this.renderer);const t=wr(e);t&&(this.renderer.setColorizeOptions({color:t}),(r=this.map)==null||r.triggerRepaint())}resetColorize(){var e;z(this.renderer),this.renderer.resetColorizeOptions(),(e=this.map)==null||e.triggerRepaint()}setMapColorize(e,t){var s;z(this.renderer);const r=wr(t);r&&(this.renderer.setMapColorizeOptions(e,{color:r}),(s=this.map)==null||s.triggerRepaint())}resetMapColorize(e){var t;z(this.renderer),this.renderer.resetMapColorizeOptions(e),(t=this.map)==null||t.triggerRepaint()}clear(){var e;z(this.renderer),this.renderer.clear(),(e=this.map)==null||e.triggerRepaint()}preparerender(){}render(){if(!this.map||!this.renderer)return;const e=this.map.getCanvas(),t=[e.width/window.devicePixelRatio,e.height/window.devicePixelRatio],r=this.map.getCenter(),s=fe([r.lng,r.lat]),n=this.map.unproject([0,t[1]]),o=this.map.unproject([t[0],t[1]]),a=this.map.unproject([t[0],0]),h=this.map.unproject([0,0]),c=fe([n.lng,n.lat]),l=fe([o.lng,o.lat]),u=fe([a.lng,a.lat]),m=fe([h.lng,h.lat]),g=Di([c,l,u,m]),y=Dr(g,t),_=-(this.map.getBearing()/180)*Math.PI,I=new Nr(t,s,y,_,window.devicePixelRatio);this.renderer.render(I)}addEventListeners(){this.renderer&&(this.renderer.addEventListener(k.CHANGED,this.render.bind(this)),this.renderer.addEventListener(k.IMAGEINFOLOADED,this.render.bind(this)),this.renderer.addEventListener(k.WARPEDMAPENTER,this.passWarpedMapEvent.bind(this)),this.renderer.addEventListener(k.WARPEDMAPLEAVE,this.passWarpedMapEvent.bind(this)),this.renderer.tileCache.addEventListener(k.FIRSTMAPTILELOADED,this.passWarpedMapEvent.bind(this)),this.renderer.tileCache.addEventListener(k.ALLREQUESTEDTILESLOADED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.addEventListener(k.GEOREFERENCEANNOTATIONADDED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.addEventListener(k.WARPEDMAPADDED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.addEventListener(k.WARPEDMAPREMOVED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.addEventListener(k.VISIBILITYCHANGED,this.render.bind(this)),this.renderer.warpedMapList.addEventListener(k.CLEARED,this.render.bind(this)))}removeEventListeners(){this.renderer&&(this.renderer.removeEventListener(k.CHANGED,this.render.bind(this)),this.renderer.removeEventListener(k.IMAGEINFOLOADED,this.render.bind(this)),this.renderer.removeEventListener(k.WARPEDMAPENTER,this.passWarpedMapEvent.bind(this)),this.renderer.removeEventListener(k.WARPEDMAPLEAVE,this.passWarpedMapEvent.bind(this)),this.renderer.tileCache.removeEventListener(k.FIRSTMAPTILELOADED,this.passWarpedMapEvent.bind(this)),this.renderer.tileCache.removeEventListener(k.ALLREQUESTEDTILESLOADED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.removeEventListener(k.GEOREFERENCEANNOTATIONADDED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.removeEventListener(k.WARPEDMAPADDED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.removeEventListener(k.WARPEDMAPREMOVED,this.passWarpedMapEvent.bind(this)),this.renderer.warpedMapList.removeEventListener(k.VISIBILITYCHANGED,this.render.bind(this)),this.renderer.warpedMapList.removeEventListener(k.CLEARED,this.render.bind(this)))}passWarpedMapEvent(e){e instanceof Z&&this.map&&this.map.fire(e.type,e.data)}}exports.WarpedMapLayer=hf;
2
441
  //# sourceMappingURL=index.cjs55.js.map