WorkerTileHandler-53EXBVCL.js 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774
  1. import {
  2. o
  3. } from "./chunk-DBT4KOKX.js";
  4. import {
  5. T,
  6. l as l2,
  7. m as m2,
  8. t as t5
  9. } from "./chunk-LC47RING.js";
  10. import {
  11. I,
  12. L
  13. } from "./chunk-L553EHL3.js";
  14. import {
  15. a as a2,
  16. l,
  17. m,
  18. n as n4,
  19. o as o2,
  20. p as p2,
  21. u
  22. } from "./chunk-2GP5D74I.js";
  23. import {
  24. _,
  25. c as c2,
  26. i,
  27. n as n2,
  28. r as r2
  29. } from "./chunk-JXYBFGFY.js";
  30. import "./chunk-EPMXCACW.js";
  31. import {
  32. C
  33. } from "./chunk-UCPKJYXN.js";
  34. import {
  35. t as t2
  36. } from "./chunk-KFLNKWNF.js";
  37. import {
  38. s,
  39. t as t3
  40. } from "./chunk-R24MO4IV.js";
  41. import {
  42. P,
  43. a,
  44. b,
  45. f,
  46. h,
  47. n as n3,
  48. r as r3,
  49. t as t4
  50. } from "./chunk-YQBYWPBD.js";
  51. import {
  52. x
  53. } from "./chunk-UWKVAZQ6.js";
  54. import "./chunk-QISOH77W.js";
  55. import "./chunk-XO5VJRK4.js";
  56. import "./chunk-4OM3EX6P.js";
  57. import "./chunk-3OFVLRSL.js";
  58. import "./chunk-5FHRTN6L.js";
  59. import "./chunk-NDUYF7XW.js";
  60. import {
  61. n
  62. } from "./chunk-CFVLY6NB.js";
  63. import "./chunk-X4SA4ELJ.js";
  64. import "./chunk-ZLNEXZAN.js";
  65. import "./chunk-ZYRIJWLX.js";
  66. import "./chunk-RYY6632W.js";
  67. import "./chunk-DW42UVIT.js";
  68. import "./chunk-YAEIHDJH.js";
  69. import "./chunk-TJNOJH33.js";
  70. import "./chunk-OSHI574D.js";
  71. import "./chunk-DVUG3KID.js";
  72. import "./chunk-FWSQEIAR.js";
  73. import "./chunk-VEGAOVMY.js";
  74. import {
  75. t
  76. } from "./chunk-U2XHEJM7.js";
  77. import "./chunk-SQOPWYIT.js";
  78. import {
  79. j,
  80. p
  81. } from "./chunk-V6P2MAQQ.js";
  82. import "./chunk-E5O6P5I2.js";
  83. import {
  84. c
  85. } from "./chunk-SPWQ3AWG.js";
  86. import "./chunk-2TIUKVZN.js";
  87. import {
  88. r
  89. } from "./chunk-YXWMMD76.js";
  90. import "./chunk-S5KM4IGW.js";
  91. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/ScriptUtils.js
  92. function e(e3) {
  93. return 746 === e3 || 747 === e3 || !(e3 < 4352) && (e3 >= 12704 && e3 <= 12735 || (e3 >= 12544 && e3 <= 12591 || (e3 >= 65072 && e3 <= 65103 && !(e3 >= 65097 && e3 <= 65103) || (e3 >= 63744 && e3 <= 64255 || (e3 >= 13056 && e3 <= 13311 || (e3 >= 11904 && e3 <= 12031 || (e3 >= 12736 && e3 <= 12783 || (e3 >= 12288 && e3 <= 12351 && !(e3 >= 12296 && e3 <= 12305 || e3 >= 12308 && e3 <= 12319 || 12336 === e3) || (e3 >= 13312 && e3 <= 19903 || (e3 >= 19968 && e3 <= 40959 || (e3 >= 12800 && e3 <= 13055 || (e3 >= 12592 && e3 <= 12687 || (e3 >= 43360 && e3 <= 43391 || (e3 >= 55216 && e3 <= 55295 || (e3 >= 4352 && e3 <= 4607 || (e3 >= 44032 && e3 <= 55215 || (e3 >= 12352 && e3 <= 12447 || (e3 >= 12272 && e3 <= 12287 || (e3 >= 12688 && e3 <= 12703 || (e3 >= 12032 && e3 <= 12255 || (e3 >= 12784 && e3 <= 12799 || (e3 >= 12448 && e3 <= 12543 && 12540 !== e3 || (e3 >= 65280 && e3 <= 65519 && !(65288 === e3 || 65289 === e3 || 65293 === e3 || e3 >= 65306 && e3 <= 65310 || 65339 === e3 || 65341 === e3 || 65343 === e3 || e3 >= 65371 && e3 <= 65503 || 65507 === e3 || e3 >= 65512 && e3 <= 65519) || (e3 >= 65104 && e3 <= 65135 && !(e3 >= 65112 && e3 <= 65118 || e3 >= 65123 && e3 <= 65126) || (e3 >= 5120 && e3 <= 5759 || (e3 >= 6320 && e3 <= 6399 || (e3 >= 65040 && e3 <= 65055 || (e3 >= 19904 && e3 <= 19967 || (e3 >= 40960 && e3 <= 42127 || e3 >= 42128 && e3 <= 42191)))))))))))))))))))))))))))));
  94. }
  95. function c3(e3) {
  96. return !(e3 < 11904) && (e3 >= 12704 && e3 <= 12735 || (e3 >= 12544 && e3 <= 12591 || (e3 >= 65072 && e3 <= 65103 || (e3 >= 63744 && e3 <= 64255 || (e3 >= 13056 && e3 <= 13311 || (e3 >= 11904 && e3 <= 12031 || (e3 >= 12736 && e3 <= 12783 || (e3 >= 12288 && e3 <= 12351 || (e3 >= 13312 && e3 <= 19903 || (e3 >= 19968 && e3 <= 40959 || (e3 >= 12800 && e3 <= 13055 || (e3 >= 65280 && e3 <= 65519 || (e3 >= 12352 && e3 <= 12447 || (e3 >= 12272 && e3 <= 12287 || (e3 >= 12032 && e3 <= 12255 || (e3 >= 12784 && e3 <= 12799 || (e3 >= 12448 && e3 <= 12543 || (e3 >= 65040 && e3 <= 65055 || (e3 >= 42128 && e3 <= 42191 || e3 >= 40960 && e3 <= 42127)))))))))))))))))));
  97. }
  98. function s2(e3) {
  99. switch (e3) {
  100. case 10:
  101. case 32:
  102. case 38:
  103. case 40:
  104. case 41:
  105. case 43:
  106. case 45:
  107. case 47:
  108. case 173:
  109. case 183:
  110. case 8203:
  111. case 8208:
  112. case 8211:
  113. case 8231:
  114. return true;
  115. }
  116. return false;
  117. }
  118. function a3(e3) {
  119. switch (e3) {
  120. case 9:
  121. case 10:
  122. case 11:
  123. case 12:
  124. case 13:
  125. case 32:
  126. return true;
  127. }
  128. return false;
  129. }
  130. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/TextShaping.js
  131. var c4 = 24;
  132. var h2 = 17;
  133. var a4 = class {
  134. constructor(t8, e3, i2, s6, o5, c5, h4) {
  135. this._glyphItems = t8, this._maxWidth = e3, this._lineHeight = i2, this._letterSpacing = s6, this._hAnchor = o5, this._vAnchor = c5, this._justify = h4;
  136. }
  137. getShaping(o5, c5, h4) {
  138. const a7 = this._letterSpacing, l4 = this._lineHeight, r8 = this._justify, n6 = this._maxWidth, m3 = [];
  139. let f3 = 0, p4 = 0;
  140. const g2 = o5.length;
  141. for (let t8 = 0; t8 < g2; t8++) {
  142. const e3 = o5.charCodeAt(t8), i2 = h4 && e(e3);
  143. let c6;
  144. for (const t9 of this._glyphItems)
  145. if (c6 = t9[e3], c6)
  146. break;
  147. m3.push({ codePoint: e3, x: f3, y: p4, vertical: i2, glyphMosaicItem: c6 }), c6 && (f3 += c6.metrics.advance + a7);
  148. }
  149. let y2 = f3;
  150. if (n6 > 0) {
  151. y2 = f3 / Math.max(1, Math.ceil(f3 / n6));
  152. }
  153. const d = o5.includes("\u200B"), x3 = [];
  154. for (let e3 = 0; e3 < g2 - 1; e3++) {
  155. const s6 = m3[e3].codePoint, o6 = c3(s6);
  156. if (s2(s6) || o6) {
  157. let t8 = 0;
  158. if (10 === s6)
  159. t8 -= 1e4;
  160. else if (o6 && d)
  161. t8 += 150;
  162. else {
  163. 40 !== s6 && 65288 !== s6 || (t8 += 50);
  164. const i2 = m3[e3 + 1].codePoint;
  165. 41 !== i2 && 65289 !== i2 || (t8 += 50);
  166. }
  167. x3.push(this._buildBreak(e3 + 1, m3[e3].x, y2, x3, t8, false));
  168. }
  169. }
  170. const M = this._optimalBreaks(this._buildBreak(g2, f3, y2, x3, 0, true));
  171. let u4 = 0;
  172. const _2 = c5 ? -l4 : l4;
  173. let I5 = 0;
  174. for (let t8 = 0; t8 < M.length; t8++) {
  175. const i2 = M[t8];
  176. let s6 = I5;
  177. for (; s6 < i2 && a3(m3[s6].codePoint); )
  178. m3[s6].glyphMosaicItem = null, ++s6;
  179. let o6 = i2 - 1;
  180. for (; o6 > s6 && a3(m3[o6].codePoint); )
  181. m3[o6].glyphMosaicItem = null, --o6;
  182. if (s6 <= o6) {
  183. const t9 = m3[s6].x;
  184. for (let i3 = s6; i3 <= o6; i3++)
  185. m3[i3].x -= t9, m3[i3].y = p4;
  186. let e3 = m3[o6].x;
  187. m3[o6].glyphMosaicItem && (e3 += m3[o6].glyphMosaicItem.metrics.advance), u4 = Math.max(e3, u4), r8 && this._applyJustification(m3, s6, o6);
  188. }
  189. I5 = i2, p4 += _2;
  190. }
  191. if (m3.length > 0) {
  192. const t8 = M.length - 1, e3 = (r8 - this._hAnchor) * u4;
  193. let i2 = (-this._vAnchor * (t8 + 1) + 0.5) * l4;
  194. c5 && t8 && (i2 += t8 * l4);
  195. for (const s6 of m3)
  196. s6.x += e3, s6.y += i2;
  197. }
  198. return m3.filter((t8) => t8.glyphMosaicItem);
  199. }
  200. static getTextBox(t8, e3) {
  201. if (!t8.length)
  202. return null;
  203. let i2 = 1 / 0, s6 = 1 / 0, o5 = 0, c5 = 0;
  204. for (const a7 of t8) {
  205. const t9 = a7.glyphMosaicItem.metrics.advance, l4 = a7.x, r8 = a7.y - h2, n6 = l4 + t9, m3 = r8 + e3;
  206. i2 = Math.min(i2, l4), o5 = Math.max(o5, n6), s6 = Math.min(s6, r8), c5 = Math.max(c5, m3);
  207. }
  208. return { x: i2, y: s6, width: o5 - i2, height: c5 - s6 };
  209. }
  210. static getBox(t8) {
  211. if (!t8.length)
  212. return null;
  213. let e3 = 1 / 0, i2 = 1 / 0, s6 = 0, o5 = 0;
  214. for (const c5 of t8) {
  215. const { height: t9, left: h4, top: a7, width: l4 } = c5.glyphMosaicItem.metrics, r8 = c5.x, n6 = c5.y - (t9 - Math.abs(a7)), m3 = r8 + l4 + h4, f3 = n6 + t9;
  216. e3 = Math.min(e3, r8), s6 = Math.max(s6, m3), i2 = Math.min(i2, n6), o5 = Math.max(o5, f3);
  217. }
  218. return { x: e3, y: i2, width: s6 - e3, height: o5 - i2 };
  219. }
  220. static addDecoration(t8, e3) {
  221. const i2 = t8.length;
  222. if (0 === i2)
  223. return;
  224. const s6 = 3;
  225. let c5 = t8[0].x + t8[0].glyphMosaicItem.metrics.left, h4 = t8[0].y;
  226. for (let l4 = 1; l4 < i2; l4++) {
  227. const i3 = t8[l4];
  228. if (i3.y !== h4) {
  229. const a8 = t8[l4 - 1].x + t8[l4 - 1].glyphMosaicItem.metrics.left + t8[l4 - 1].glyphMosaicItem.metrics.width;
  230. t8.push({ codePoint: 0, x: c5, y: h4 + e3 - s6, vertical: false, glyphMosaicItem: { sdf: true, rect: new t2(4, 0, 4, 8), metrics: { width: a8 - c5, height: 2 + 2 * s6, left: 0, top: 0, advance: 0 }, page: 0, code: 0 } }), h4 = i3.y, c5 = i3.x + i3.glyphMosaicItem.metrics.left;
  231. }
  232. }
  233. const a7 = t8[i2 - 1].x + t8[i2 - 1].glyphMosaicItem.metrics.left + t8[i2 - 1].glyphMosaicItem.metrics.width;
  234. t8.push({ codePoint: 0, x: c5, y: h4 + e3 - s6, vertical: false, glyphMosaicItem: { sdf: true, rect: new t2(4, 0, 4, 8), metrics: { width: a7 - c5, height: 2 + 2 * s6, left: 0, top: 0, advance: 0 }, page: 0, code: 0 } });
  235. }
  236. _breakScore(t8, e3, i2, s6) {
  237. const o5 = (t8 - e3) * (t8 - e3);
  238. return s6 ? t8 < e3 ? o5 / 2 : 2 * o5 : o5 + Math.abs(i2) * i2;
  239. }
  240. _buildBreak(t8, e3, i2, s6, o5, c5) {
  241. let h4 = null, a7 = this._breakScore(e3, i2, o5, c5);
  242. for (const l4 of s6) {
  243. const t9 = e3 - l4.x, s7 = this._breakScore(t9, i2, o5, c5) + l4.score;
  244. s7 <= a7 && (h4 = l4, a7 = s7);
  245. }
  246. return { index: t8, x: e3, score: a7, previousBreak: h4 };
  247. }
  248. _optimalBreaks(t8) {
  249. return t8 ? this._optimalBreaks(t8.previousBreak).concat(t8.index) : [];
  250. }
  251. _applyJustification(t8, e3, i2) {
  252. const s6 = t8[i2], o5 = s6.vertical ? c4 : s6.glyphMosaicItem ? s6.glyphMosaicItem.metrics.advance : 0, h4 = (s6.x + o5) * this._justify;
  253. for (let c5 = e3; c5 <= i2; c5++)
  254. t8[c5].x -= h4;
  255. }
  256. };
  257. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/Placement.js
  258. var x2 = 4096;
  259. var w = 8;
  260. var p3 = 0.5;
  261. var y = 2;
  262. var T2 = class {
  263. constructor(e3, t8, i2 = 0, n6 = -1, s6 = p3) {
  264. this.x = e3, this.y = t8, this.angle = i2, this.segment = n6, this.minzoom = s6;
  265. }
  266. };
  267. var f2 = class {
  268. constructor(e3, t8, n6, s6, o5, a7 = p3, l4 = n3) {
  269. this.anchor = e3, this.labelAngle = t8, this.glyphAngle = n6, this.page = s6, this.alternateVerticalGlyph = o5, this.minzoom = a7, this.maxzoom = l4;
  270. }
  271. };
  272. var I2 = class {
  273. constructor(e3, t8, i2, n6, s6, o5, a7, l4, h4, r8, c5, g2) {
  274. this.tl = e3, this.tr = t8, this.bl = i2, this.br = n6, this.mosaicRect = s6, this.labelAngle = o5, this.minAngle = a7, this.maxAngle = l4, this.anchor = h4, this.minzoom = r8, this.maxzoom = c5, this.page = g2;
  275. }
  276. };
  277. var b2 = class {
  278. constructor(e3) {
  279. this.shapes = e3;
  280. }
  281. };
  282. var u2 = class {
  283. getIconPlacement(i2, n6, s6) {
  284. const o5 = new t3(i2.x, i2.y), a7 = s6.rotationAlignment === l.MAP, l4 = s6.keepUpright;
  285. let h4 = s6.rotate * f;
  286. a7 && (h4 += i2.angle);
  287. const g2 = new b2([]);
  288. return s6.allowOverlap && s6.ignorePlacement || !o || (g2.iconColliders = []), this._addIconPlacement(g2, o5, n6, s6, h4), a7 && l4 && this._addIconPlacement(g2, o5, n6, s6, h4 + t4), g2;
  289. }
  290. _addIconPlacement(e3, t8, n6, s6, o5) {
  291. const a7 = n6.pixelRatio, l4 = n6.width / a7, h4 = n6.height / a7, c5 = s6.offset;
  292. let x3 = c5[0], d = c5[1];
  293. switch (s6.anchor) {
  294. case m.CENTER:
  295. x3 -= l4 / 2, d -= h4 / 2;
  296. break;
  297. case m.LEFT:
  298. d -= h4 / 2;
  299. break;
  300. case m.RIGHT:
  301. x3 -= l4, d -= h4 / 2;
  302. break;
  303. case m.TOP:
  304. x3 -= l4 / 2;
  305. break;
  306. case m.BOTTOM:
  307. x3 -= l4 / 2, d -= h4;
  308. break;
  309. case m.TOP_LEFT:
  310. break;
  311. case m.BOTTOM_LEFT:
  312. d -= h4;
  313. break;
  314. case m.TOP_RIGHT:
  315. x3 -= l4;
  316. break;
  317. case m.BOTTOM_RIGHT:
  318. x3 -= l4, d -= h4;
  319. }
  320. const w3 = n6.rect, y2 = 2 / a7, T4 = x3 - y2, f3 = d - y2, b4 = T4 + w3.width / a7, u4 = f3 + w3.height / a7, P2 = new t3(T4, f3), O = new t3(b4, u4), _2 = new t3(T4, u4), k = new t3(b4, f3);
  321. if (0 !== o5) {
  322. const e4 = Math.cos(o5), t9 = Math.sin(o5);
  323. P2.rotate(e4, t9), O.rotate(e4, t9), _2.rotate(e4, t9), k.rotate(e4, t9);
  324. }
  325. const M = new I2(P2, k, _2, O, w3, o5, 0, 256, t8, p3, n3, 0);
  326. if (e3.shapes.push(M), (!s6.allowOverlap || !s6.ignorePlacement) && o) {
  327. const n7 = s6.size, a8 = s6.padding, r8 = { xTile: t8.x, yTile: t8.y, dxPixels: x3 * n7 - a8, dyPixels: d * n7 - a8, hard: !s6.optional, partIndex: 0, width: l4 * n7 + 2 * a8, height: h4 * n7 + 2 * a8, angle: o5, minLod: p3, maxLod: n3 };
  328. e3.iconColliders.push(r8);
  329. }
  330. }
  331. getTextPlacement(n6, s6, o5, r8) {
  332. const x3 = new t3(n6.x, n6.y), d = r8.rotate * f, T4 = r8.rotationAlignment === l.MAP, u4 = r8.keepUpright, P2 = r8.padding;
  333. let O = p3;
  334. const _2 = !T4 ? 0 : n6.angle, k = n6.segment >= 0 && T4, M = r8.allowOverlap && r8.ignorePlacement ? null : [], E = [], G = 4, N = !k;
  335. let A2 = Number.POSITIVE_INFINITY, L2 = Number.NEGATIVE_INFINITY, z = A2, F = L2;
  336. const v = (k || T4) && u4, R = r8.size / c4;
  337. let B2 = false;
  338. for (const e3 of s6)
  339. if (e3.vertical) {
  340. B2 = true;
  341. break;
  342. }
  343. let H, V = 0, j2 = 0;
  344. if (!k && B2) {
  345. const e3 = a4.getTextBox(s6, r8.lineHeight * c4);
  346. switch (r8.anchor) {
  347. case m.LEFT:
  348. V = e3.height / 2, j2 = -e3.width / 2;
  349. break;
  350. case m.RIGHT:
  351. V = -e3.height / 2, j2 = e3.width / 2;
  352. break;
  353. case m.TOP:
  354. V = e3.height / 2, j2 = e3.width / 2;
  355. break;
  356. case m.BOTTOM:
  357. V = -e3.height / 2, j2 = -e3.width / 2;
  358. break;
  359. case m.TOP_LEFT:
  360. V = e3.height;
  361. break;
  362. case m.BOTTOM_LEFT:
  363. j2 = -e3.width;
  364. break;
  365. case m.TOP_RIGHT:
  366. j2 = e3.width;
  367. break;
  368. case m.BOTTOM_RIGHT:
  369. V = -e3.height;
  370. }
  371. }
  372. V += r8.offset[0] * c4, j2 += r8.offset[1] * c4;
  373. for (const e3 of s6) {
  374. const s7 = e3.glyphMosaicItem;
  375. if (!s7 || s7.rect.isEmpty)
  376. continue;
  377. const a7 = s7.rect, l4 = s7.metrics, c5 = s7.page;
  378. if (M && N) {
  379. if (void 0 !== H && H !== e3.y) {
  380. let e4, t8, s8, o6;
  381. B2 ? (e4 = -F + V, t8 = A2 + j2, s8 = F - z, o6 = L2 - A2) : (e4 = A2 + V, t8 = z + j2, s8 = L2 - A2, o6 = F - z);
  382. const a8 = { xTile: n6.x, yTile: n6.y, dxPixels: e4 * R - P2, dyPixels: t8 * R - P2, hard: !r8.optional, partIndex: 1, width: s8 * R + 2 * P2, height: o6 * R + 2 * P2, angle: d, minLod: p3, maxLod: n3 };
  383. M.push(a8), A2 = Number.POSITIVE_INFINITY, L2 = Number.NEGATIVE_INFINITY, z = A2, F = L2;
  384. }
  385. H = e3.y;
  386. }
  387. const g2 = [];
  388. if (k) {
  389. const t8 = 0.5 * s7.metrics.width, i2 = (e3.x + l4.left - G + t8) * R * w;
  390. if (O = this._placeGlyph(n6, O, i2, o5, n6.segment, 1, e3.vertical, c5, g2), u4 && (O = this._placeGlyph(n6, O, i2, o5, n6.segment, -1, e3.vertical, c5, g2)), O >= y)
  391. break;
  392. } else
  393. g2.push(new f2(x3, _2, _2, c5, false)), T4 && u4 && g2.push(new f2(x3, _2 + t4, _2 + t4, c5, false));
  394. const b4 = e3.x + l4.left, C3 = e3.y - h2 - l4.top, S = b4 + l4.width, Y = C3 + l4.height;
  395. let q, U, D, J, K, Q, W, X;
  396. if (!k && B2)
  397. if (e3.vertical) {
  398. const e4 = (b4 + S) / 2 - l4.height / 2, t8 = (C3 + Y) / 2 + l4.width / 2;
  399. q = new t3(-t8 - G + V, e4 - G + j2), U = new t3(q.x + a7.width, q.y + a7.height), D = new t3(q.x, U.y), J = new t3(U.x, q.y);
  400. } else
  401. q = new t3(-C3 + G + V, b4 - G + j2), U = new t3(q.x - a7.height, q.y + a7.width), D = new t3(U.x, q.y), J = new t3(q.x, U.y);
  402. else
  403. q = new t3(b4 - G + V, C3 - G + j2), U = new t3(q.x + a7.width, q.y + a7.height), D = new t3(q.x, U.y), J = new t3(U.x, q.y);
  404. for (const t8 of g2) {
  405. let i2, s8, o6, h4;
  406. if (t8.alternateVerticalGlyph) {
  407. if (!K) {
  408. const e4 = (C3 + Y) / 2 + j2;
  409. K = new t3((b4 + S) / 2 + V - l4.height / 2 - G, e4 + l4.width / 2 + G), Q = new t3(K.x + a7.height, K.y - a7.width), W = new t3(Q.x, K.y), X = new t3(K.x, Q.y);
  410. }
  411. i2 = K, s8 = W, o6 = X, h4 = Q;
  412. } else
  413. i2 = q, s8 = D, o6 = J, h4 = U;
  414. const c6 = C3, g3 = Y, x4 = t8.glyphAngle + d;
  415. if (0 !== x4) {
  416. const e4 = Math.cos(x4), t9 = Math.sin(x4);
  417. i2 = i2.clone(), s8 = s8.clone(), o6 = o6.clone(), h4 = h4.clone(), i2.rotate(e4, t9), h4.rotate(e4, t9), s8.rotate(e4, t9), o6.rotate(e4, t9);
  418. }
  419. let w3 = 0, p4 = 256;
  420. if (k && B2 ? e3.vertical ? t8.alternateVerticalGlyph ? (w3 = 32, p4 = 96) : (w3 = 224, p4 = 32) : (w3 = 224, p4 = 96) : (w3 = 192, p4 = 64), E.push(new I2(i2, o6, s8, h4, a7, t8.labelAngle, w3, p4, t8.anchor, t8.minzoom, t8.maxzoom, t8.page)), M && (!v || this._legible(t8.labelAngle))) {
  421. if (N)
  422. b4 < A2 && (A2 = b4), c6 < z && (z = c6), S > L2 && (L2 = S), g3 > F && (F = g3);
  423. else if (t8.minzoom < y) {
  424. const e4 = { xTile: n6.x, yTile: n6.y, dxPixels: (b4 + V) * R - P2, dyPixels: (c6 + V) * R - P2, hard: !r8.optional, partIndex: 1, width: (S - b4) * R + 2 * P2, height: (g3 - c6) * R + 2 * P2, angle: x4, minLod: t8.minzoom, maxLod: t8.maxzoom };
  425. M.push(e4);
  426. }
  427. }
  428. }
  429. }
  430. if (O >= y)
  431. return null;
  432. if (M && N) {
  433. let e3, t8, s7, o6;
  434. B2 ? (e3 = -F + V, t8 = A2 + j2, s7 = F - z, o6 = L2 - A2) : (e3 = A2 + V, t8 = z + j2, s7 = L2 - A2, o6 = F - z);
  435. const a7 = { xTile: n6.x, yTile: n6.y, dxPixels: e3 * R - P2, dyPixels: t8 * R - P2, hard: !r8.optional, partIndex: 1, width: s7 * R + 2 * P2, height: o6 * R + 2 * P2, angle: d, minLod: p3, maxLod: n3 };
  436. M.push(a7);
  437. }
  438. const C2 = new b2(E);
  439. return M && M.length > 0 && (C2.textColliders = M), C2;
  440. }
  441. _legible(e3) {
  442. const t8 = h(e3);
  443. return t8 < 65 || t8 >= 193;
  444. }
  445. _placeGlyph(e3, n6, a7, l4, h4, r8, c5, g2, x3) {
  446. let d = r8;
  447. const w3 = d < 0 ? a(e3.angle + t4, r3) : e3.angle;
  448. let p4 = 0;
  449. a7 < 0 && (d *= -1, a7 *= -1, p4 = t4), d > 0 && ++h4;
  450. let y2 = new t3(e3.x, e3.y), T4 = l4[h4], I5 = n3;
  451. if (l4.length <= h4)
  452. return I5;
  453. for (; ; ) {
  454. const e4 = T4.x - y2.x, t8 = T4.y - y2.y, i2 = Math.sqrt(e4 * e4 + t8 * t8), r9 = Math.max(a7 / i2, n6), m3 = e4 / i2, b4 = t8 / i2, u4 = a(Math.atan2(b4, m3) + p4, r3);
  455. if (x3.push(new f2(y2, w3, u4, g2, false, r9, I5)), c5 && x3.push(new f2(y2, w3, u4, g2, true, r9, I5)), r9 <= n6)
  456. return r9;
  457. y2 = T4.clone();
  458. do {
  459. if (h4 += d, l4.length <= h4 || h4 < 0)
  460. return r9;
  461. T4 = l4[h4];
  462. } while (y2.isEqual(T4));
  463. let P2 = T4.x - y2.x, O = T4.y - y2.y;
  464. const _2 = Math.sqrt(P2 * P2 + O * O);
  465. P2 *= i2 / _2, O *= i2 / _2, y2.x -= P2, y2.y -= O, I5 = r9;
  466. }
  467. }
  468. };
  469. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/Feature.js
  470. var t6;
  471. !function(e3) {
  472. e3[e3.moveTo = 1] = "moveTo", e3[e3.lineTo = 2] = "lineTo", e3[e3.close = 7] = "close";
  473. }(t6 || (t6 = {}));
  474. var s3 = class {
  475. constructor(e3, t8) {
  476. this.values = {}, this._geometry = void 0, this._pbfGeometry = null;
  477. const s6 = t8.keys, o5 = t8.values, r8 = e3.asUnsafe();
  478. for (; r8.next(); )
  479. switch (r8.tag()) {
  480. case 1:
  481. this.id = r8.getUInt64();
  482. break;
  483. case 2: {
  484. const e4 = r8.getMessage().asUnsafe(), t9 = this.values;
  485. for (; !e4.empty(); ) {
  486. const r9 = e4.getUInt32(), a7 = e4.getUInt32();
  487. t9[s6[r9]] = o5[a7];
  488. }
  489. e4.release();
  490. break;
  491. }
  492. case 3:
  493. this.type = r8.getUInt32();
  494. break;
  495. case 4:
  496. this._pbfGeometry = r8.getMessage();
  497. break;
  498. default:
  499. r8.skip();
  500. }
  501. }
  502. getGeometry(s6) {
  503. if (void 0 !== this._geometry)
  504. return this._geometry;
  505. if (!this._pbfGeometry)
  506. return null;
  507. const o5 = this._pbfGeometry.asUnsafe();
  508. let r8, a7;
  509. this._pbfGeometry = null, s6 ? s6.reset(this.type) : r8 = [];
  510. let n6, i2 = t6.moveTo, l4 = 0, c5 = 0, h4 = 0;
  511. for (; !o5.empty(); ) {
  512. if (0 === l4) {
  513. const e3 = o5.getUInt32();
  514. i2 = 7 & e3, l4 = e3 >> 3;
  515. }
  516. switch (l4--, i2) {
  517. case t6.moveTo:
  518. c5 += o5.getSInt32(), h4 += o5.getSInt32(), s6 ? s6.moveTo(c5, h4) : r8 && (a7 && r8.push(a7), a7 = [], a7.push(new t3(c5, h4)));
  519. break;
  520. case t6.lineTo:
  521. c5 += o5.getSInt32(), h4 += o5.getSInt32(), s6 ? s6.lineTo(c5, h4) : a7 && a7.push(new t3(c5, h4));
  522. break;
  523. case t6.close:
  524. s6 ? s6.close() : a7 && !a7[0].equals(c5, h4) && a7.push(a7[0].clone());
  525. break;
  526. default:
  527. throw o5.release(), new Error("Invalid path operation");
  528. }
  529. }
  530. return s6 ? n6 = s6.result() : r8 && (a7 && r8.push(a7), n6 = r8), o5.release(), this._geometry = n6, n6;
  531. }
  532. };
  533. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/IndexMemoryBuffer.js
  534. var r4 = class extends t5 {
  535. constructor() {
  536. super(12);
  537. }
  538. add(s6, r8, t8) {
  539. const e3 = this.array;
  540. e3.push(s6), e3.push(r8), e3.push(t8);
  541. }
  542. };
  543. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/SourceLayerData.js
  544. var e2 = class {
  545. constructor(t8) {
  546. this.extent = 4096, this.keys = [], this.values = [], this._pbfLayer = t8.clone();
  547. const s6 = t8.asUnsafe();
  548. for (; s6.next(); )
  549. switch (s6.tag()) {
  550. case 1:
  551. this.name = s6.getString();
  552. break;
  553. case 3:
  554. this.keys.push(s6.getString());
  555. break;
  556. case 4:
  557. this.values.push(s6.processMessage(e2._parseValue));
  558. break;
  559. case 5:
  560. this.extent = s6.getUInt32();
  561. break;
  562. default:
  563. s6.skip();
  564. }
  565. }
  566. getData() {
  567. return this._pbfLayer;
  568. }
  569. static _parseValue(e3) {
  570. for (; e3.next(); )
  571. switch (e3.tag()) {
  572. case 1:
  573. return e3.getString();
  574. case 2:
  575. return e3.getFloat();
  576. case 3:
  577. return e3.getDouble();
  578. case 4:
  579. return e3.getInt64();
  580. case 5:
  581. return e3.getUInt64();
  582. case 6:
  583. return e3.getSInt64();
  584. case 7:
  585. return e3.getBool();
  586. default:
  587. e3.skip();
  588. }
  589. return null;
  590. }
  591. };
  592. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/VertexMemoryBuffer.js
  593. var o3 = class extends t5 {
  594. constructor(t8) {
  595. super(t8);
  596. }
  597. add(t8, o5, r8, u4, h4, a7, n6, d, e3, p4, i2, c5) {
  598. const M = this.array;
  599. let l4 = t5.i1616to32(t8, o5);
  600. M.push(l4);
  601. const m3 = 31;
  602. l4 = t5.i8888to32(Math.round(m3 * r8), Math.round(m3 * u4), Math.round(m3 * h4), Math.round(m3 * a7)), M.push(l4), l4 = t5.i8888to32(Math.round(m3 * n6), Math.round(m3 * d), Math.round(m3 * e3), Math.round(m3 * p4)), M.push(l4), l4 = t5.i1616to32(i2, 0), M.push(l4), c5 && M.push(...c5);
  603. }
  604. };
  605. var r5 = class extends t5 {
  606. constructor(t8) {
  607. super(t8);
  608. }
  609. add(t8, o5, r8) {
  610. const u4 = this.array;
  611. u4.push(t5.i1616to32(t8, o5)), r8 && u4.push(...r8);
  612. }
  613. };
  614. var u3 = class extends t5 {
  615. constructor(t8) {
  616. super(t8);
  617. }
  618. add(t8, o5, r8, u4, h4, a7, n6) {
  619. const d = this.array, e3 = this.index;
  620. let p4 = t5.i1616to32(t8, o5);
  621. d.push(p4);
  622. const i2 = 15;
  623. return p4 = t5.i8888to32(Math.round(i2 * r8), Math.round(i2 * u4), h4, a7), d.push(p4), n6 && d.push(...n6), e3;
  624. }
  625. };
  626. var h3 = class extends t5 {
  627. constructor(t8) {
  628. super(t8);
  629. }
  630. add(o5, r8, u4, h4, a7, n6, d, e3, p4, i2, c5, M) {
  631. const l4 = this.array;
  632. let m3 = t5.i1616to32(o5, r8);
  633. l4.push(m3), m3 = t5.i1616to32(Math.round(8 * u4), Math.round(8 * h4)), l4.push(m3), m3 = t5.i8888to32(a7 / 4, n6 / 4, e3, p4), l4.push(m3), m3 = t5.i8888to32(0, h(d), 10 * i2, Math.min(10 * c5, 255)), l4.push(m3), M && l4.push(...M);
  634. }
  635. };
  636. var a5 = class extends t5 {
  637. constructor(t8) {
  638. super(t8);
  639. }
  640. add(t8, o5, r8, u4, h4) {
  641. const a7 = this.array, n6 = t5.i1616to32(2 * t8 + r8, 2 * o5 + u4);
  642. a7.push(n6), h4 && a7.push(...h4);
  643. }
  644. };
  645. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/buckets/BaseBucket.js
  646. var t7 = class {
  647. constructor(t8, e3, s6) {
  648. this.layerExtent = 4096, this._features = [], this.layer = t8, this.zoom = e3, this._spriteInfo = s6, this._filter = t8.getFeatureFilter();
  649. }
  650. pushFeature(t8) {
  651. this._filter && !this._filter.filter(t8, this.zoom) || this._features.push(t8);
  652. }
  653. hasFeatures() {
  654. return this._features.length > 0;
  655. }
  656. getResources(t8, e3, s6) {
  657. }
  658. };
  659. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/buckets/CircleBucket.js
  660. var r6 = class extends t7 {
  661. constructor(t8, r8, i2, c5, s6) {
  662. super(t8, r8, i2), this.type = I.CIRCLE, this._circleVertexBuffer = c5, this._circleIndexBuffer = s6;
  663. }
  664. get circleIndexStart() {
  665. return this._circleIndexStart;
  666. }
  667. get circleIndexCount() {
  668. return this._circleIndexCount;
  669. }
  670. processFeatures(e3) {
  671. const t8 = this._circleVertexBuffer, r8 = this._circleIndexBuffer;
  672. this._circleIndexStart = 3 * r8.index, this._circleIndexCount = 0;
  673. const i2 = this.layer, c5 = this.zoom;
  674. e3 && e3.setExtent(this.layerExtent);
  675. for (const s6 of this._features) {
  676. const n6 = s6.getGeometry(e3);
  677. if (!n6)
  678. continue;
  679. const l4 = i2.circleMaterial.encodeAttributes(s6, c5, i2);
  680. for (const e4 of n6)
  681. if (e4)
  682. for (const i3 of e4) {
  683. const e5 = t8.index;
  684. t8.add(i3.x, i3.y, 0, 0, l4), t8.add(i3.x, i3.y, 0, 1, l4), t8.add(i3.x, i3.y, 1, 0, l4), t8.add(i3.x, i3.y, 1, 1, l4), r8.add(e5 + 0, e5 + 1, e5 + 2), r8.add(e5 + 1, e5 + 2, e5 + 3), this._circleIndexCount += 6;
  685. }
  686. }
  687. }
  688. serialize() {
  689. let e3 = 6;
  690. e3 += this.layerUIDs.length, e3 += this._circleVertexBuffer.array.length, e3 += this._circleIndexBuffer.array.length;
  691. const t8 = new Uint32Array(e3), r8 = new Int32Array(t8.buffer);
  692. let i2 = 0;
  693. t8[i2++] = this.type, t8[i2++] = this.layerUIDs.length;
  694. for (let c5 = 0; c5 < this.layerUIDs.length; c5++)
  695. t8[i2++] = this.layerUIDs[c5];
  696. t8[i2++] = this._circleIndexStart, t8[i2++] = this._circleIndexCount, t8[i2++] = this._circleVertexBuffer.array.length;
  697. for (let c5 = 0; c5 < this._circleVertexBuffer.array.length; c5++)
  698. r8[i2++] = this._circleVertexBuffer.array[c5];
  699. t8[i2++] = this._circleIndexBuffer.array.length;
  700. for (let c5 = 0; c5 < this._circleIndexBuffer.array.length; c5++)
  701. t8[i2++] = this._circleIndexBuffer.array[c5];
  702. return t8.buffer;
  703. }
  704. };
  705. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/buckets/FillBucket.js
  706. var s4 = class extends t7 {
  707. constructor(t8, e3, i2, l4, n6, s6, o5) {
  708. super(t8, e3, i2), this.type = I.FILL, this._patternMap = /* @__PURE__ */ new Map(), this._fillVertexBuffer = l4, this._fillIndexBuffer = n6, this._outlineVertexBuffer = s6, this._outlineIndexBuffer = o5;
  709. }
  710. get fillIndexStart() {
  711. return this._fillIndexStart;
  712. }
  713. get fillIndexCount() {
  714. return this._fillIndexCount;
  715. }
  716. get outlineIndexStart() {
  717. return this._outlineIndexStart;
  718. }
  719. get outlineIndexCount() {
  720. return this._outlineIndexCount;
  721. }
  722. getResources(t8, e3, i2) {
  723. const r8 = this.layer, l4 = this.zoom, n6 = r8.getPaintProperty("fill-pattern");
  724. if (n6)
  725. if (n6.isDataDriven)
  726. for (const s6 of this._features)
  727. e3(n6.getValue(l4, s6), true);
  728. else
  729. e3(n6.getValue(l4), true);
  730. }
  731. processFeatures(t8) {
  732. this._fillIndexStart = 3 * this._fillIndexBuffer.index, this._fillIndexCount = 0, this._outlineIndexStart = 3 * this._outlineIndexBuffer.index, this._outlineIndexCount = 0;
  733. const e3 = this.layer, i2 = this.zoom, { fillMaterial: r8, outlineMaterial: l4, hasDataDrivenFill: n6, hasDataDrivenOutline: s6 } = e3;
  734. t8 && t8.setExtent(this.layerExtent);
  735. const o5 = e3.getPaintProperty("fill-pattern"), a7 = o5 == null ? void 0 : o5.isDataDriven;
  736. let f3 = !o5 && e3.getPaintValue("fill-antialias", i2);
  737. if (e3.outlineUsesFillColor) {
  738. if (f3 && !e3.hasDataDrivenOpacity) {
  739. const t9 = e3.getPaintValue("fill-opacity", i2), r9 = e3.getPaintValue("fill-opacity", i2 + 1);
  740. t9 < 1 && r9 < 1 && (f3 = false);
  741. }
  742. if (f3 && !e3.hasDataDrivenColor) {
  743. const t9 = e3.getPaintValue("fill-color", i2), r9 = e3.getPaintValue("fill-color", i2 + 1);
  744. t9[3] < 1 && r9[3] < 1 && (f3 = false);
  745. }
  746. }
  747. const u4 = this._features, d = t8 == null ? void 0 : t8.validateTessellation;
  748. if (a7) {
  749. const n7 = [];
  750. for (const a8 of u4) {
  751. const u5 = o5.getValue(i2, a8), h4 = this._spriteInfo[u5];
  752. if (!h4 || !h4.rect)
  753. continue;
  754. const x3 = r8.encodeAttributes(a8, i2, e3, h4), c5 = f3 && s6 ? l4.encodeAttributes(a8, i2, e3) : [], _2 = a8.getGeometry(t8);
  755. n7.push({ ddFillAttributes: x3, ddOutlineAttributes: c5, page: h4.page, geometry: _2 }), n7.sort((t9, e4) => t9.page - e4.page);
  756. for (const { ddFillAttributes: t9, ddOutlineAttributes: i3, page: r9, geometry: l5 } of n7)
  757. this._processFeature(l5, f3, e3.outlineUsesFillColor, t9, i3, d, r9);
  758. }
  759. } else
  760. for (const h4 of u4) {
  761. const o6 = n6 ? r8.encodeAttributes(h4, i2, e3) : null, a8 = f3 && s6 ? l4.encodeAttributes(h4, i2, e3) : null, u5 = h4.getGeometry(t8);
  762. this._processFeature(u5, f3, e3.outlineUsesFillColor, o6, a8, d);
  763. }
  764. }
  765. serialize() {
  766. let t8 = 10;
  767. t8 += this.layerUIDs.length, t8 += this._fillVertexBuffer.array.length, t8 += this._fillIndexBuffer.array.length, t8 += this._outlineVertexBuffer.array.length, t8 += this._outlineIndexBuffer.array.length, t8 += 3 * this._patternMap.size + 1;
  768. const e3 = new Uint32Array(t8), i2 = new Int32Array(e3.buffer);
  769. let r8 = 0;
  770. e3[r8++] = this.type, e3[r8++] = this.layerUIDs.length;
  771. for (let s6 = 0; s6 < this.layerUIDs.length; s6++)
  772. e3[r8++] = this.layerUIDs[s6];
  773. e3[r8++] = this._fillIndexStart, e3[r8++] = this._fillIndexCount, e3[r8++] = this._outlineIndexStart, e3[r8++] = this._outlineIndexCount;
  774. const l4 = this._patternMap, n6 = l4.size;
  775. if (e3[r8++] = n6, n6 > 0)
  776. for (const [s6, [o5, a7]] of l4)
  777. e3[r8++] = s6, e3[r8++] = o5, e3[r8++] = a7;
  778. e3[r8++] = this._fillVertexBuffer.array.length;
  779. for (let s6 = 0; s6 < this._fillVertexBuffer.array.length; s6++)
  780. i2[r8++] = this._fillVertexBuffer.array[s6];
  781. e3[r8++] = this._fillIndexBuffer.array.length;
  782. for (let s6 = 0; s6 < this._fillIndexBuffer.array.length; s6++)
  783. e3[r8++] = this._fillIndexBuffer.array[s6];
  784. e3[r8++] = this._outlineVertexBuffer.array.length;
  785. for (let s6 = 0; s6 < this._outlineVertexBuffer.array.length; s6++)
  786. i2[r8++] = this._outlineVertexBuffer.array[s6];
  787. e3[r8++] = this._outlineIndexBuffer.array.length;
  788. for (let s6 = 0; s6 < this._outlineIndexBuffer.array.length; s6++)
  789. e3[r8++] = this._outlineIndexBuffer.array[s6];
  790. return e3.buffer;
  791. }
  792. _processFeature(t8, e3, i2, r8, l4, n6, o5) {
  793. if (!t8)
  794. return;
  795. const a7 = t8.length, f3 = !l4 || 0 === l4.length;
  796. if (e3 && (!i2 || f3))
  797. for (let s6 = 0; s6 < a7; s6++)
  798. this._processOutline(t8[s6], l4);
  799. const u4 = 32;
  800. let d;
  801. for (let h4 = 0; h4 < a7; h4++) {
  802. const e4 = s4._area(t8[h4]);
  803. e4 > u4 ? (void 0 !== d && this._processFill(t8, d, r8, n6, o5), d = [h4]) : e4 < -u4 && void 0 !== d && d.push(h4);
  804. }
  805. void 0 !== d && this._processFill(t8, d, r8, n6, o5);
  806. }
  807. _processOutline(t8, e3) {
  808. const i2 = this._outlineVertexBuffer, r8 = this._outlineIndexBuffer, l4 = r8.index;
  809. let s6, o5, a7;
  810. const f3 = new t3(0, 0), u4 = new t3(0, 0), d = new t3(0, 0);
  811. let h4 = -1, x3 = -1, c5 = -1, _2 = -1, y2 = -1, g2 = false;
  812. const p4 = 0;
  813. let I5 = t8.length;
  814. if (I5 < 2)
  815. return;
  816. const B2 = t8[p4];
  817. let m3 = t8[I5 - 1];
  818. for (; I5 && m3.isEqual(B2); )
  819. --I5, m3 = t8[I5 - 1];
  820. if (!(I5 - p4 < 2)) {
  821. for (let l5 = p4; l5 < I5; ++l5) {
  822. l5 === p4 ? (s6 = t8[I5 - 1], o5 = t8[p4], a7 = t8[p4 + 1], f3.assignSub(o5, s6), f3.normalize(), f3.rightPerpendicular()) : (s6 = o5, o5 = a7, a7 = l5 !== I5 - 1 ? t8[l5 + 1] : t8[p4], f3.assign(u4));
  823. const n6 = this._isClipEdge(s6, o5);
  824. -1 === _2 && (g2 = n6), u4.assignSub(a7, o5), u4.normalize(), u4.rightPerpendicular();
  825. const B3 = f3.x * u4.y - f3.y * u4.x;
  826. d.assignAdd(f3, u4), d.normalize();
  827. const m4 = -d.x * -f3.x + -d.y * -f3.y;
  828. let V = Math.abs(0 !== m4 ? 1 / m4 : 1);
  829. V > 8 && (V = 8), B3 >= 0 ? (c5 = i2.add(o5.x, o5.y, f3.x, f3.y, 0, 1, e3), -1 === _2 && (_2 = c5), h4 >= 0 && x3 >= 0 && c5 >= 0 && !n6 && r8.add(h4, x3, c5), x3 = i2.add(o5.x, o5.y, V * -d.x, V * -d.y, 0, -1, e3), -1 === y2 && (y2 = x3), h4 >= 0 && x3 >= 0 && c5 >= 0 && !n6 && r8.add(h4, x3, c5), h4 = x3, x3 = c5, c5 = i2.add(o5.x, o5.y, d.x, d.y, 0, 1, e3), h4 >= 0 && x3 >= 0 && c5 >= 0 && !n6 && r8.add(h4, x3, c5), x3 = i2.add(o5.x, o5.y, u4.x, u4.y, 0, 1, e3), h4 >= 0 && x3 >= 0 && c5 >= 0 && !n6 && r8.add(h4, x3, c5)) : (c5 = i2.add(o5.x, o5.y, V * d.x, V * d.y, 0, 1, e3), -1 === _2 && (_2 = c5), h4 >= 0 && x3 >= 0 && c5 >= 0 && !n6 && r8.add(h4, x3, c5), x3 = i2.add(o5.x, o5.y, -f3.x, -f3.y, 0, -1, e3), -1 === y2 && (y2 = x3), h4 >= 0 && x3 >= 0 && c5 >= 0 && !n6 && r8.add(h4, x3, c5), h4 = x3, x3 = c5, c5 = i2.add(o5.x, o5.y, -d.x, -d.y, 0, -1, e3), h4 >= 0 && x3 >= 0 && c5 >= 0 && !n6 && r8.add(h4, x3, c5), h4 = i2.add(o5.x, o5.y, -u4.x, -u4.y, 0, -1, e3), h4 >= 0 && x3 >= 0 && c5 >= 0 && !n6 && r8.add(h4, x3, c5));
  830. }
  831. h4 >= 0 && x3 >= 0 && _2 >= 0 && !g2 && r8.add(h4, x3, _2), h4 >= 0 && _2 >= 0 && y2 >= 0 && !g2 && r8.add(h4, y2, _2), this._outlineIndexCount += 3 * (r8.index - l4);
  832. }
  833. }
  834. _processFill(r8, l4, n6, s6, o5) {
  835. s6 = true;
  836. let a7;
  837. l4.length > 1 && (a7 = []);
  838. let f3 = 0;
  839. for (const t8 of l4)
  840. 0 !== f3 && a7.push(f3), f3 += r8[t8].length;
  841. const u4 = 2 * f3, d = t.acquire();
  842. for (const t8 of l4) {
  843. const e3 = r8[t8], i2 = e3.length;
  844. for (let t9 = 0; t9 < i2; ++t9)
  845. d.push(e3[t9].x, e3[t9].y);
  846. }
  847. const h4 = x(d, a7, 2);
  848. if (s6 && x.deviation(d, a7, 2, h4) > 0) {
  849. const t8 = l4.map((t9) => r8[t9].length), { buffer: e3, vertexCount: s7 } = r2(d, t8);
  850. if (s7 > 0) {
  851. const t9 = this._fillVertexBuffer.index;
  852. for (let i2 = 0; i2 < s7; i2++)
  853. this._fillVertexBuffer.add(e3[2 * i2], e3[2 * i2 + 1], n6);
  854. for (let e4 = 0; e4 < s7; e4 += 3) {
  855. const i2 = t9 + e4;
  856. this._fillIndexBuffer.add(i2, i2 + 1, i2 + 2);
  857. }
  858. if (void 0 !== o5) {
  859. const t10 = this._patternMap, e4 = t10.get(o5);
  860. e4 ? e4[1] += s7 : t10.set(o5, [this._fillIndexStart + this._fillIndexCount, s7]);
  861. }
  862. this._fillIndexCount += s7;
  863. }
  864. } else {
  865. const t8 = h4.length;
  866. if (t8 > 0) {
  867. const e3 = this._fillVertexBuffer.index;
  868. let i2 = 0;
  869. for (; i2 < u4; )
  870. this._fillVertexBuffer.add(d[i2++], d[i2++], n6);
  871. let r9 = 0;
  872. for (; r9 < t8; )
  873. this._fillIndexBuffer.add(e3 + h4[r9++], e3 + h4[r9++], e3 + h4[r9++]);
  874. if (void 0 !== o5) {
  875. const e4 = this._patternMap, i3 = e4.get(o5);
  876. i3 ? i3[1] += t8 : e4.set(o5, [this._fillIndexStart + this._fillIndexCount, t8]);
  877. }
  878. this._fillIndexCount += t8;
  879. }
  880. }
  881. t.release(d);
  882. }
  883. _isClipEdge(t8, e3) {
  884. return t8.x === e3.x ? t8.x <= -64 || t8.x >= 4160 : t8.y === e3.y && (t8.y <= -64 || t8.y >= 4160);
  885. }
  886. static _area(t8) {
  887. let e3 = 0;
  888. const i2 = t8.length - 1;
  889. for (let r8 = 0; r8 < i2; r8++)
  890. e3 += (t8[r8].x - t8[r8 + 1].x) * (t8[r8].y + t8[r8 + 1].y);
  891. return e3 += (t8[i2].x - t8[0].x) * (t8[i2].y + t8[0].y), 0.5 * e3;
  892. }
  893. };
  894. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/buckets/LineBucket.js
  895. var s5 = 65535;
  896. var n5 = class extends t7 {
  897. constructor(t8, s6, n6, a7, o5) {
  898. super(t8, s6, n6), this.type = I.LINE, this._tessellationOptions = { pixelCoordRatio: 8, halfWidth: 0, offset: 0 }, this._patternMap = /* @__PURE__ */ new Map(), this.tessellationProperties = { _lineVertexBuffer: null, _lineIndexBuffer: null, _ddValues: null }, this.tessellationProperties._lineVertexBuffer = a7, this.tessellationProperties._lineIndexBuffer = o5, this._lineTessellator = new c2(r7(this.tessellationProperties), l3(this.tessellationProperties), t8.canUseThinTessellation);
  899. }
  900. get lineIndexStart() {
  901. return this._lineIndexStart;
  902. }
  903. get lineIndexCount() {
  904. return this._lineIndexCount;
  905. }
  906. getResources(e3, t8, i2) {
  907. const s6 = this.layer, n6 = this.zoom, r8 = s6.getPaintProperty("line-pattern"), l4 = s6.getPaintProperty("line-dasharray"), a7 = s6.getLayoutProperty("line-cap");
  908. if (!r8 && !l4)
  909. return;
  910. const o5 = (a7 == null ? void 0 : a7.getValue(n6)) || 0, u4 = a7 == null ? void 0 : a7.isDataDriven, f3 = r8 == null ? void 0 : r8.isDataDriven, h4 = l4 == null ? void 0 : l4.isDataDriven;
  911. if (f3 || h4)
  912. for (const p4 of this._features)
  913. t8(f3 ? r8.getValue(n6, p4) : this._getDashArrayKey(p4, n6, s6, l4, u4, a7, o5));
  914. else if (r8)
  915. t8(r8.getValue(n6));
  916. else if (l4) {
  917. const e4 = l4.getValue(n6);
  918. t8(s6.getDashKey(e4, o5));
  919. }
  920. }
  921. processFeatures(e3) {
  922. this._lineIndexStart = 3 * this.tessellationProperties._lineIndexBuffer.index, this._lineIndexCount = 0;
  923. const t8 = this.layer, i2 = this.zoom, s6 = this._features, n6 = this._tessellationOptions, { hasDataDrivenLine: r8, lineMaterial: l4 } = t8;
  924. e3 && e3.setExtent(this.layerExtent);
  925. const a7 = t8.getPaintProperty("line-pattern"), o5 = t8.getPaintProperty("line-dasharray"), u4 = a7 == null ? void 0 : a7.isDataDriven, f3 = o5 == null ? void 0 : o5.isDataDriven;
  926. let h4;
  927. h4 = t8.getLayoutProperty("line-cap");
  928. const p4 = (h4 == null ? void 0 : h4.isDataDriven) ? h4 : null, g2 = p4 ? null : t8.getLayoutValue("line-cap", i2), y2 = g2 || 0, d = !!p4;
  929. h4 = t8.getLayoutProperty("line-join");
  930. const c5 = (h4 == null ? void 0 : h4.isDataDriven) ? h4 : null, _2 = c5 ? null : t8.getLayoutValue("line-join", i2);
  931. h4 = t8.getLayoutProperty("line-miter-limit");
  932. const x3 = (h4 == null ? void 0 : h4.isDataDriven) ? h4 : null, V = x3 ? null : t8.getLayoutValue("line-miter-limit", i2);
  933. h4 = t8.getLayoutProperty("line-round-limit");
  934. const m3 = (h4 == null ? void 0 : h4.isDataDriven) ? h4 : null, D = m3 ? null : t8.getLayoutValue("line-round-limit", i2);
  935. h4 = t8.getPaintProperty("line-width");
  936. const P2 = (h4 == null ? void 0 : h4.isDataDriven) ? h4 : null, I5 = P2 ? null : t8.getPaintValue("line-width", i2);
  937. h4 = t8.getPaintProperty("line-offset");
  938. const L2 = (h4 == null ? void 0 : h4.isDataDriven) ? h4 : null, B2 = L2 ? null : t8.getPaintValue("line-offset", i2);
  939. if (u4 || f3) {
  940. const r9 = [];
  941. for (const n7 of s6) {
  942. const s7 = u4 ? a7.getValue(i2, n7) : this._getDashArrayKey(n7, i2, t8, o5, d, p4, y2), f4 = this._spriteInfo[s7];
  943. if (!f4 || !f4.rect)
  944. continue;
  945. const h5 = l4.encodeAttributes(n7, i2, t8, f4), v = n7.getGeometry(e3);
  946. r9.push({ ddAttributes: h5, page: f4.page, cap: p4 ? p4.getValue(i2, n7) : g2, join: c5 ? c5.getValue(i2, n7) : _2, miterLimit: x3 ? x3.getValue(i2, n7) : V, roundLimit: m3 ? m3.getValue(i2, n7) : D, halfWidth: 0.5 * (P2 ? P2.getValue(i2, n7) : I5), offset: L2 ? L2.getValue(i2, n7) : B2, geometry: v });
  947. }
  948. r9.sort((e4, t9) => e4.page - t9.page), n6.textured = true;
  949. for (const { ddAttributes: e4, page: t9, cap: i3, join: s7, miterLimit: l5, roundLimit: a8, halfWidth: o6, offset: u5, geometry: f4 } of r9)
  950. n6.capType = i3, n6.joinType = s7, n6.miterLimit = l5, n6.roundLimit = a8, n6.halfWidth = o6, n6.offset = u5, this._processFeature(f4, e4, t9);
  951. } else {
  952. if (a7) {
  953. const e4 = a7.getValue(i2), t9 = this._spriteInfo[e4];
  954. if (!t9 || !t9.rect)
  955. return;
  956. }
  957. n6.textured = !(!a7 && !o5), n6.capType = g2, n6.joinType = _2, n6.miterLimit = V, n6.roundLimit = D, n6.halfWidth = 0.5 * I5, n6.offset = B2;
  958. for (const a8 of s6) {
  959. const s7 = r8 ? l4.encodeAttributes(a8, i2, t8) : null;
  960. p4 && (n6.capType = p4.getValue(i2, a8)), c5 && (n6.joinType = c5.getValue(i2, a8)), x3 && (n6.miterLimit = x3.getValue(i2, a8)), m3 && (n6.roundLimit = m3.getValue(i2, a8)), P2 && (n6.halfWidth = 0.5 * P2.getValue(i2, a8)), L2 && (n6.offset = L2.getValue(i2, a8));
  961. const o6 = a8.getGeometry(e3);
  962. this._processFeature(o6, s7);
  963. }
  964. }
  965. }
  966. serialize() {
  967. let e3 = 6;
  968. e3 += this.layerUIDs.length, e3 += this.tessellationProperties._lineVertexBuffer.array.length, e3 += this.tessellationProperties._lineIndexBuffer.array.length, e3 += 3 * this._patternMap.size + 1;
  969. const t8 = new Uint32Array(e3), i2 = new Int32Array(t8.buffer);
  970. let s6 = 0;
  971. t8[s6++] = this.type, t8[s6++] = this.layerUIDs.length;
  972. for (let l4 = 0; l4 < this.layerUIDs.length; l4++)
  973. t8[s6++] = this.layerUIDs[l4];
  974. t8[s6++] = this._lineIndexStart, t8[s6++] = this._lineIndexCount;
  975. const n6 = this._patternMap, r8 = n6.size;
  976. if (t8[s6++] = r8, r8 > 0)
  977. for (const [l4, [a7, o5]] of n6)
  978. t8[s6++] = l4, t8[s6++] = a7, t8[s6++] = o5;
  979. t8[s6++] = this.tessellationProperties._lineVertexBuffer.array.length;
  980. for (let l4 = 0; l4 < this.tessellationProperties._lineVertexBuffer.array.length; l4++)
  981. i2[s6++] = this.tessellationProperties._lineVertexBuffer.array[l4];
  982. t8[s6++] = this.tessellationProperties._lineIndexBuffer.array.length;
  983. for (let l4 = 0; l4 < this.tessellationProperties._lineIndexBuffer.array.length; l4++)
  984. t8[s6++] = this.tessellationProperties._lineIndexBuffer.array[l4];
  985. return t8.buffer;
  986. }
  987. _processFeature(e3, t8, i2) {
  988. if (!e3)
  989. return;
  990. const s6 = e3.length;
  991. for (let n6 = 0; n6 < s6; n6++)
  992. this._processGeometry(e3[n6], t8, i2);
  993. }
  994. _processGeometry(e3, t8, i2) {
  995. if (e3.length < 2)
  996. return;
  997. const n6 = 1e-3;
  998. let r8, l4, a7 = e3[0], o5 = 1;
  999. for (; o5 < e3.length; )
  1000. r8 = e3[o5].x - a7.x, l4 = e3[o5].y - a7.y, r8 * r8 + l4 * l4 < n6 * n6 ? e3.splice(o5, 1) : (a7 = e3[o5], ++o5);
  1001. if (e3.length < 2)
  1002. return;
  1003. const u4 = this.tessellationProperties._lineIndexBuffer, f3 = 3 * u4.index;
  1004. this._tessellationOptions.initialDistance = 0, this._tessellationOptions.wrapDistance = s5, this.tessellationProperties._ddValues = t8, this._lineTessellator.tessellate(e3, this._tessellationOptions);
  1005. const h4 = 3 * u4.index - f3;
  1006. if (void 0 !== i2) {
  1007. const e4 = this._patternMap, t9 = e4.get(i2);
  1008. t9 ? t9[1] += h4 : e4.set(i2, [f3 + this._lineIndexCount, h4]);
  1009. }
  1010. this._lineIndexCount += h4;
  1011. }
  1012. _getDashArrayKey(e3, t8, i2, s6, n6, r8, l4) {
  1013. const a7 = n6 ? r8.getValue(t8, e3) : l4, o5 = s6.getValue(t8, e3);
  1014. return i2.getDashKey(o5, a7);
  1015. }
  1016. };
  1017. var r7 = (e3) => (t8, i2, s6, n6, r8, l4, a7, o5, u4, f3, h4) => (e3._lineVertexBuffer.add(t8, i2, a7, o5, s6, n6, r8, l4, u4, f3, h4, e3._ddValues), e3._lineVertexBuffer.index - 1);
  1018. var l3 = (e3) => (t8, i2, s6) => {
  1019. e3._lineIndexBuffer.add(t8, i2, s6);
  1020. };
  1021. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/buckets/SymbolBucket.js
  1022. var I3 = 10;
  1023. function b3(e3, t8) {
  1024. return e3.iconMosaicItem && t8.iconMosaicItem ? e3.iconMosaicItem.page === t8.iconMosaicItem.page ? 0 : e3.iconMosaicItem.page - t8.iconMosaicItem.page : e3.iconMosaicItem && !t8.iconMosaicItem ? 1 : !e3.iconMosaicItem && t8.iconMosaicItem ? -1 : 0;
  1025. }
  1026. var A = class extends t7 {
  1027. constructor(e3, t8, i2, s6, a7, o5, r8, l4) {
  1028. super(e3, t8, l4.getSpriteItems()), this.type = I.SYMBOL, this._markerMap = /* @__PURE__ */ new Map(), this._glyphMap = /* @__PURE__ */ new Map(), this._glyphBufferDataStorage = /* @__PURE__ */ new Map(), this._isIconSDF = false, this._iconVertexBuffer = i2, this._iconIndexBuffer = s6, this._textVertexBuffer = a7, this._textIndexBuffer = o5, this._placementEngine = r8, this._workerTileHandler = l4;
  1029. }
  1030. get markerPageMap() {
  1031. return this._markerMap;
  1032. }
  1033. get glyphsPageMap() {
  1034. return this._glyphMap;
  1035. }
  1036. get symbolInstances() {
  1037. return this._symbolInstances;
  1038. }
  1039. getResources(e3, n6, i2) {
  1040. const s6 = this.layer, a7 = this.zoom;
  1041. e3 && e3.setExtent(this.layerExtent);
  1042. const o5 = s6.getLayoutProperty("icon-image"), r8 = s6.getLayoutProperty("text-field");
  1043. let l4 = s6.getLayoutProperty("text-transform"), h4 = s6.getLayoutProperty("text-font");
  1044. const x3 = [];
  1045. let c5, g2, f3, y2;
  1046. o5 && !o5.isDataDriven && (c5 = o5.getValue(a7)), r8 && !r8.isDataDriven && (g2 = r8.getValue(a7)), l4 && l4.isDataDriven || (f3 = s6.getLayoutValue("text-transform", a7), l4 = null), h4 && h4.isDataDriven || (y2 = s6.getLayoutValue("text-font", a7), h4 = null);
  1047. for (const m3 of this._features) {
  1048. const u4 = m3.getGeometry(e3);
  1049. if (!u4 || 0 === u4.length)
  1050. continue;
  1051. let p4, _2;
  1052. o5 && (p4 = o5.isDataDriven ? o5.getValue(a7, m3) : this._replaceKeys(c5, m3.values), p4 && n6(p4));
  1053. let M = false;
  1054. if (r8 && (_2 = r8.isDataDriven ? r8.getValue(a7, m3) : this._replaceKeys(g2, m3.values), _2)) {
  1055. switch (_2 = _2.replace(/\\n/g, "\n"), l4 && (f3 = l4.getValue(a7, m3)), f3) {
  1056. case o2.LOWERCASE:
  1057. _2 = _2.toLowerCase();
  1058. break;
  1059. case o2.UPPERCASE:
  1060. _2 = _2.toUpperCase();
  1061. }
  1062. if (A._bidiEngine.hasBidiChar(_2)) {
  1063. let e5;
  1064. e5 = "rtl" === A._bidiEngine.checkContextual(_2) ? "IDNNN" : "ICNNN", _2 = A._bidiEngine.bidiTransform(_2, e5, "VLYSN"), M = true;
  1065. }
  1066. const e4 = _2.length;
  1067. if (e4 > 0) {
  1068. h4 && (y2 = h4.getValue(a7, m3));
  1069. for (const t8 of y2) {
  1070. let n7 = i2[t8];
  1071. n7 || (n7 = i2[t8] = /* @__PURE__ */ new Set());
  1072. for (let t9 = 0; t9 < e4; t9++) {
  1073. const e5 = _2.charCodeAt(t9);
  1074. n7.add(e5);
  1075. }
  1076. }
  1077. }
  1078. }
  1079. if (!p4 && !_2)
  1080. continue;
  1081. const P2 = s6.getLayoutValue("symbol-sort-key", a7, m3), I5 = { feature: m3, sprite: p4, label: _2, rtl: M, geometry: u4, hash: (_2 ? c(_2) : 0) ^ (p4 ? c(p4) : 0), priority: P2, textFont: y2 };
  1082. x3.push(I5);
  1083. }
  1084. this._symbolFeatures = x3;
  1085. }
  1086. processFeatures(e3) {
  1087. e3 && e3.setExtent(this.layerExtent);
  1088. const t8 = this.layer, n6 = this.zoom, s6 = t8.getLayoutValue("symbol-placement", n6), a7 = s6 !== n4.POINT, c5 = t8.getLayoutValue("symbol-spacing", n6) * w, d = t8.getLayoutProperty("icon-image"), P2 = t8.getLayoutProperty("text-field"), I5 = d ? new T(t8, n6, a7) : null, L2 = P2 ? new m2(t8, n6, a7) : null, V = this._workerTileHandler;
  1089. let T4;
  1090. d && (T4 = V.getSpriteItems()), this._iconIndexStart = 3 * this._iconIndexBuffer.index, this._textIndexStart = 3 * this._textIndexBuffer.index, this._iconIndexCount = 0, this._textIndexCount = 0, this._markerMap.clear(), this._glyphMap.clear();
  1091. const w3 = [];
  1092. let B2 = 1;
  1093. L2 && L2.size && (B2 = L2.size / c4);
  1094. const C2 = L2 ? L2.maxAngle * f : 0, R = L2 ? L2.size * w : 0;
  1095. for (const i2 of this._symbolFeatures) {
  1096. let e4;
  1097. I5 && T4 && i2.sprite && (e4 = T4[i2.sprite], e4 && e4.sdf && (this._isIconSDF = true));
  1098. let t9;
  1099. !!e4 && I5.update(n6, i2.feature);
  1100. let d2 = 0;
  1101. const p4 = i2.label;
  1102. if (p4) {
  1103. L2.update(n6, i2.feature);
  1104. const e5 = a7 && L2.rotationAlignment === l.MAP ? L2.keepUpright : L2.writingMode && L2.writingMode.includes(p2.VERTICAL);
  1105. let s7 = 0.5;
  1106. switch (L2.anchor) {
  1107. case m.TOP_LEFT:
  1108. case m.LEFT:
  1109. case m.BOTTOM_LEFT:
  1110. s7 = 0;
  1111. break;
  1112. case m.TOP_RIGHT:
  1113. case m.RIGHT:
  1114. case m.BOTTOM_RIGHT:
  1115. s7 = 1;
  1116. }
  1117. let r8 = 0.5;
  1118. switch (L2.anchor) {
  1119. case m.TOP_LEFT:
  1120. case m.TOP:
  1121. case m.TOP_RIGHT:
  1122. r8 = 0;
  1123. break;
  1124. case m.BOTTOM_LEFT:
  1125. case m.BOTTOM:
  1126. case m.BOTTOM_RIGHT:
  1127. r8 = 1;
  1128. }
  1129. let l4 = 0.5;
  1130. switch (L2.justify) {
  1131. case u.AUTO:
  1132. l4 = s7;
  1133. break;
  1134. case u.LEFT:
  1135. l4 = 0;
  1136. break;
  1137. case u.RIGHT:
  1138. l4 = 1;
  1139. }
  1140. const c6 = L2.letterSpacing * c4, g2 = a7 ? 0 : L2.maxWidth * c4, _2 = L2.lineHeight * c4, M = i2.textFont.map((e6) => V.getGlyphItems(e6));
  1141. if (t9 = new a4(M, g2, _2, c6, s7, r8, l4).getShaping(p4, i2.rtl, e5), t9 && t9.length > 0) {
  1142. let e6 = 1e30, n7 = -1e30;
  1143. for (const i3 of t9)
  1144. e6 = Math.min(e6, i3.x), n7 = Math.max(n7, i3.x);
  1145. d2 = (n7 - e6 + 2 * c4) * B2 * w;
  1146. }
  1147. }
  1148. for (let n7 of i2.geometry) {
  1149. const h4 = [];
  1150. if (s6 === n4.LINE) {
  1151. if (t9 && t9.length > 0 && L2 && L2.size) {
  1152. const e5 = L2.size * w * (2 + Math.min(2, 4 * Math.abs(L2.offset[1])));
  1153. n7 = A._smoothVertices(n7, e5);
  1154. }
  1155. A._pushAnchors(h4, n7, c5, d2);
  1156. } else
  1157. s6 === n4.LINE_CENTER ? A._pushCenterAnchor(h4, n7) : i2.feature.type === s.Polygon ? A._pushCentroid(h4, n7) : h4.push(new T2(n7[0].x, n7[0].y));
  1158. for (const s7 of h4) {
  1159. if (s7.x < 0 || s7.x > x2 || s7.y < 0 || s7.y > x2)
  1160. continue;
  1161. if (a7 && d2 > 0 && L2.rotationAlignment === l.MAP && !A._honorsTextMaxAngle(n7, s7, d2, C2, R))
  1162. continue;
  1163. const o5 = { shaping: t9, line: n7, iconMosaicItem: e4, anchor: s7, symbolFeature: i2, textColliders: [], iconColliders: [], textVertexRanges: [], iconVertexRanges: [] };
  1164. w3.push(o5), this._processFeature(o5, I5, L2);
  1165. }
  1166. }
  1167. }
  1168. w3.sort(b3), this._addPlacedGlyphs(), this._symbolInstances = w3;
  1169. }
  1170. serialize() {
  1171. let e3 = 11;
  1172. e3 += this.layerUIDs.length, e3 += 3 * this.markerPageMap.size, e3 += 3 * this.glyphsPageMap.size, e3 += A._symbolsSerializationLength(this._symbolInstances), e3 += this._iconVertexBuffer.array.length, e3 += this._iconIndexBuffer.array.length, e3 += this._textVertexBuffer.array.length, e3 += this._textIndexBuffer.array.length;
  1173. const t8 = new Uint32Array(e3), n6 = new Int32Array(t8.buffer), i2 = new Float32Array(t8.buffer);
  1174. let s6 = 0;
  1175. t8[s6++] = this.type, t8[s6++] = this.layerUIDs.length;
  1176. for (let a7 = 0; a7 < this.layerUIDs.length; a7++)
  1177. t8[s6++] = this.layerUIDs[a7];
  1178. t8[s6++] = this._isIconSDF ? 1 : 0, t8[s6++] = this.markerPageMap.size;
  1179. for (const [a7, [o5, r8]] of this.markerPageMap)
  1180. t8[s6++] = a7, t8[s6++] = o5, t8[s6++] = r8;
  1181. t8[s6++] = this.glyphsPageMap.size;
  1182. for (const [a7, [o5, r8]] of this.glyphsPageMap)
  1183. t8[s6++] = a7, t8[s6++] = o5, t8[s6++] = r8;
  1184. t8[s6++] = this._iconVertexBuffer.index / 4, t8[s6++] = this._textVertexBuffer.index / 4, s6 = A.serializeSymbols(t8, n6, i2, s6, this._symbolInstances), t8[s6++] = this._iconVertexBuffer.array.length;
  1185. for (let a7 = 0; a7 < this._iconVertexBuffer.array.length; a7++)
  1186. n6[s6++] = this._iconVertexBuffer.array[a7];
  1187. t8[s6++] = this._iconIndexBuffer.array.length;
  1188. for (let a7 = 0; a7 < this._iconIndexBuffer.array.length; a7++)
  1189. t8[s6++] = this._iconIndexBuffer.array[a7];
  1190. t8[s6++] = this._textVertexBuffer.array.length;
  1191. for (let a7 = 0; a7 < this._textVertexBuffer.array.length; a7++)
  1192. n6[s6++] = this._textVertexBuffer.array[a7];
  1193. t8[s6++] = this._textIndexBuffer.array.length;
  1194. for (let a7 = 0; a7 < this._textIndexBuffer.array.length; a7++)
  1195. t8[s6++] = this._textIndexBuffer.array[a7];
  1196. return t8.buffer;
  1197. }
  1198. static _symbolsSerializationLength(e3) {
  1199. let t8 = 0;
  1200. t8 += 1;
  1201. for (const n6 of e3 || []) {
  1202. t8 += 4, t8 += 1;
  1203. for (const e4 of n6.textColliders)
  1204. t8 += I3;
  1205. for (const e4 of n6.iconColliders)
  1206. t8 += I3;
  1207. t8 += 1, t8 += 2 * n6.textVertexRanges.length, t8 += 1, t8 += 2 * n6.iconVertexRanges.length;
  1208. }
  1209. return t8;
  1210. }
  1211. static serializeSymbols(e3, t8, n6, i2, s6) {
  1212. s6 = s6 || [], t8[i2++] = s6.length;
  1213. for (const a7 of s6) {
  1214. t8[i2++] = a7.anchor.x, t8[i2++] = a7.anchor.y, t8[i2++] = a7.symbolFeature.hash, t8[i2++] = a7.symbolFeature.priority, t8[i2++] = a7.textColliders.length + a7.iconColliders.length;
  1215. for (const e4 of a7.textColliders)
  1216. t8[i2++] = e4.xTile, t8[i2++] = e4.yTile, t8[i2++] = e4.dxPixels, t8[i2++] = e4.dyPixels, t8[i2++] = e4.hard ? 1 : 0, t8[i2++] = e4.partIndex, n6[i2++] = e4.minLod, n6[i2++] = e4.maxLod, t8[i2++] = e4.width, t8[i2++] = e4.height;
  1217. for (const e4 of a7.iconColliders)
  1218. t8[i2++] = e4.xTile, t8[i2++] = e4.yTile, t8[i2++] = e4.dxPixels, t8[i2++] = e4.dyPixels, t8[i2++] = e4.hard ? 1 : 0, t8[i2++] = e4.partIndex, n6[i2++] = e4.minLod, n6[i2++] = e4.maxLod, t8[i2++] = e4.width, t8[i2++] = e4.height;
  1219. t8[i2++] = a7.textVertexRanges.length;
  1220. for (const [e4, n7] of a7.textVertexRanges)
  1221. t8[i2++] = e4, t8[i2++] = n7;
  1222. t8[i2++] = a7.iconVertexRanges.length;
  1223. for (const [e4, n7] of a7.iconVertexRanges)
  1224. t8[i2++] = e4, t8[i2++] = n7;
  1225. }
  1226. return i2;
  1227. }
  1228. _replaceKeys(e3, t8) {
  1229. return e3.replace(/{([^{}]+)}/g, (e4, n6) => n6 in t8 ? t8[n6] : "");
  1230. }
  1231. _processFeature(e3, t8, n6) {
  1232. const { line: i2, iconMosaicItem: a7, shaping: o5, anchor: r8 } = e3, l4 = this.zoom, h4 = this.layer, x3 = !!a7;
  1233. let c5 = true;
  1234. x3 && (c5 = t8.optional || !a7);
  1235. const d = o5 && o5.length > 0;
  1236. let g2, y2, m3 = true;
  1237. if (d && (m3 = n6.optional), x3 && (g2 = this._placementEngine.getIconPlacement(r8, a7, t8)), (g2 || c5) && (d && (y2 = this._placementEngine.getTextPlacement(r8, o5, i2, n6)), y2 || m3)) {
  1238. if (g2 && y2 || (m3 || c5 ? m3 || y2 ? c5 || g2 || (y2 = null) : g2 = null : (g2 = null, y2 = null)), y2) {
  1239. const t9 = h4.hasDataDrivenText ? h4.textMaterial.encodeAttributes(e3.symbolFeature.feature, l4, h4) : null;
  1240. if (this._storePlacedGlyphs(e3, y2.shapes, l4, n6.rotationAlignment, t9), y2.textColliders) {
  1241. e3.textColliders = y2.textColliders;
  1242. for (const e4 of y2.textColliders) {
  1243. e4.minLod = Math.max(l4 + P(e4.minLod), 0), e4.maxLod = Math.min(l4 + P(e4.maxLod), 25);
  1244. const t10 = e4.angle;
  1245. if (t10) {
  1246. const n7 = Math.cos(t10), i3 = Math.sin(t10), s6 = e4.dxPixels * n7 - e4.dyPixels * i3, a8 = e4.dxPixels * i3 + e4.dyPixels * n7, o6 = (e4.dxPixels + e4.width) * n7 - e4.dyPixels * i3, r9 = (e4.dxPixels + e4.width) * i3 + e4.dyPixels * n7, l5 = e4.dxPixels * n7 - (e4.dyPixels + e4.height) * i3, h5 = e4.dxPixels * i3 + (e4.dyPixels + e4.height) * n7, x4 = (e4.dxPixels + e4.width) * n7 - (e4.dyPixels + e4.height) * i3, c6 = (e4.dxPixels + e4.width) * i3 + (e4.dyPixels + e4.height) * n7, d2 = Math.min(s6, o6, l5, x4), g3 = Math.max(s6, o6, l5, x4), f3 = Math.min(a8, r9, h5, c6), y3 = Math.max(a8, r9, h5, c6);
  1247. e4.dxPixels = d2, e4.dyPixels = f3, e4.width = g3 - d2, e4.height = y3 - f3;
  1248. }
  1249. }
  1250. }
  1251. }
  1252. if (g2) {
  1253. const n7 = h4.hasDataDrivenIcon ? h4.iconMaterial.encodeAttributes(e3.symbolFeature.feature, l4, h4) : null;
  1254. if (this._addPlacedIcons(e3, g2.shapes, l4, a7.page, t8.rotationAlignment === l.VIEWPORT, n7), g2.iconColliders) {
  1255. e3.iconColliders = g2.iconColliders;
  1256. for (const e4 of g2.iconColliders) {
  1257. e4.minLod = Math.max(l4 + P(e4.minLod), 0), e4.maxLod = Math.min(l4 + P(e4.maxLod), 25);
  1258. const t9 = e4.angle;
  1259. if (t9) {
  1260. const n8 = Math.cos(t9), i3 = Math.sin(t9), s6 = e4.dxPixels * n8 - e4.dyPixels * i3, a8 = e4.dxPixels * i3 + e4.dyPixels * n8, o6 = (e4.dxPixels + e4.width) * n8 - e4.dyPixels * i3, r9 = (e4.dxPixels + e4.width) * i3 + e4.dyPixels * n8, l5 = e4.dxPixels * n8 - (e4.dyPixels + e4.height) * i3, h5 = e4.dxPixels * i3 + (e4.dyPixels + e4.height) * n8, x4 = (e4.dxPixels + e4.width) * n8 - (e4.dyPixels + e4.height) * i3, c6 = (e4.dxPixels + e4.width) * i3 + (e4.dyPixels + e4.height) * n8, d2 = Math.min(s6, o6, l5, x4), g3 = Math.max(s6, o6, l5, x4), f3 = Math.min(a8, r9, h5, c6), y3 = Math.max(a8, r9, h5, c6);
  1261. e4.dxPixels = d2, e4.dyPixels = f3, e4.width = g3 - d2, e4.height = y3 - f3;
  1262. }
  1263. }
  1264. }
  1265. }
  1266. }
  1267. }
  1268. _addPlacedIcons(e3, t8, n6, i2, a7, o5) {
  1269. const r8 = Math.max(n6 - 1, 0), l4 = this._iconVertexBuffer, h4 = this._iconIndexBuffer, x3 = this._markerMap;
  1270. for (const c5 of t8) {
  1271. const t9 = a7 ? 0 : Math.max(n6 + P(c5.minzoom), r8), d = a7 ? 25 : Math.min(n6 + P(c5.maxzoom), 25);
  1272. if (d <= t9)
  1273. continue;
  1274. const g2 = c5.tl, f3 = c5.tr, y2 = c5.bl, m3 = c5.br, u4 = c5.mosaicRect, p4 = c5.labelAngle, _2 = c5.minAngle, M = c5.maxAngle, P2 = c5.anchor, I5 = l4.index, b4 = u4.x, A2 = u4.y, L2 = b4 + u4.width, V = A2 + u4.height, T4 = l4.index;
  1275. l4.add(P2.x, P2.y, g2.x, g2.y, b4, A2, p4, _2, M, t9, d, o5), l4.add(P2.x, P2.y, f3.x, f3.y, L2, A2, p4, _2, M, t9, d, o5), l4.add(P2.x, P2.y, y2.x, y2.y, b4, V, p4, _2, M, t9, d, o5), l4.add(P2.x, P2.y, m3.x, m3.y, L2, V, p4, _2, M, t9, d, o5), e3.iconVertexRanges.length > 0 && e3.iconVertexRanges[0][0] + e3.iconVertexRanges[0][1] === T4 ? e3.iconVertexRanges[0][1] += 4 : e3.iconVertexRanges.push([T4, 4]), h4.add(I5 + 0, I5 + 1, I5 + 2), h4.add(I5 + 1, I5 + 2, I5 + 3), x3.has(i2) ? x3.get(i2)[1] += 6 : x3.set(i2, [this._iconIndexStart + this._iconIndexCount, 6]), this._iconIndexCount += 6;
  1276. }
  1277. }
  1278. _addPlacedGlyphs() {
  1279. const e3 = this._textVertexBuffer, t8 = this._textIndexBuffer, n6 = this._glyphMap;
  1280. for (const [i2, s6] of this._glyphBufferDataStorage)
  1281. for (const a7 of s6) {
  1282. const s7 = e3.index, o5 = a7.symbolInstance, r8 = a7.ddAttributes, l4 = e3.index;
  1283. e3.add(a7.glyphAnchor[0], a7.glyphAnchor[1], a7.tl[0], a7.tl[1], a7.xmin, a7.ymin, a7.labelAngle, a7.minAngle, a7.maxAngle, a7.minLod, a7.maxLod, r8), e3.add(a7.glyphAnchor[0], a7.glyphAnchor[1], a7.tr[0], a7.tr[1], a7.xmax, a7.ymin, a7.labelAngle, a7.minAngle, a7.maxAngle, a7.minLod, a7.maxLod, r8), e3.add(a7.glyphAnchor[0], a7.glyphAnchor[1], a7.bl[0], a7.bl[1], a7.xmin, a7.ymax, a7.labelAngle, a7.minAngle, a7.maxAngle, a7.minLod, a7.maxLod, r8), e3.add(a7.glyphAnchor[0], a7.glyphAnchor[1], a7.br[0], a7.br[1], a7.xmax, a7.ymax, a7.labelAngle, a7.minAngle, a7.maxAngle, a7.minLod, a7.maxLod, r8), o5.textVertexRanges.length > 0 && o5.textVertexRanges[0][0] + o5.textVertexRanges[0][1] === l4 ? o5.textVertexRanges[0][1] += 4 : o5.textVertexRanges.push([l4, 4]), t8.add(s7 + 0, s7 + 1, s7 + 2), t8.add(s7 + 1, s7 + 2, s7 + 3), n6.has(i2) ? n6.get(i2)[1] += 6 : n6.set(i2, [this._textIndexStart + this._textIndexCount, 6]), this._textIndexCount += 6;
  1284. }
  1285. this._glyphBufferDataStorage.clear();
  1286. }
  1287. _storePlacedGlyphs(e3, t8, n6, i2, a7) {
  1288. const o5 = Math.max(n6 - 1, 0), r8 = i2 === l.VIEWPORT;
  1289. let l4, h4, x3, c5, d, g2, y2, m3, u4, p4, _2;
  1290. for (const f3 of t8) {
  1291. if (l4 = r8 ? 0 : Math.max(n6 + P(f3.minzoom), o5), h4 = r8 ? 25 : Math.min(n6 + P(f3.maxzoom), 25), h4 <= l4)
  1292. continue;
  1293. x3 = f3.tl, c5 = f3.tr, d = f3.bl, g2 = f3.br, y2 = f3.labelAngle, m3 = f3.minAngle, u4 = f3.maxAngle, p4 = f3.anchor, _2 = f3.mosaicRect, this._glyphBufferDataStorage.has(f3.page) || this._glyphBufferDataStorage.set(f3.page, []);
  1294. this._glyphBufferDataStorage.get(f3.page).push({ glyphAnchor: [p4.x, p4.y], tl: [x3.x, x3.y], tr: [c5.x, c5.y], bl: [d.x, d.y], br: [g2.x, g2.y], xmin: _2.x, ymin: _2.y, xmax: _2.x + _2.width, ymax: _2.y + _2.height, labelAngle: y2, minAngle: m3, maxAngle: u4, minLod: l4, maxLod: h4, placementLod: o5, symbolInstance: e3, ddAttributes: a7 });
  1295. }
  1296. }
  1297. static _pushAnchors(e3, t8, n6, i2) {
  1298. n6 += i2;
  1299. let s6 = 0;
  1300. const o5 = t8.length - 1;
  1301. for (let a7 = 0; a7 < o5; a7++)
  1302. s6 += t3.distance(t8[a7], t8[a7 + 1]);
  1303. let l4 = i2 || n6;
  1304. if (l4 *= 0.5, s6 <= l4)
  1305. return;
  1306. const h4 = l4 / s6;
  1307. let x3 = 0, c5 = -(n6 = s6 / Math.max(Math.round(s6 / n6), 1)) / 2;
  1308. const d = t8.length - 1;
  1309. for (let g2 = 0; g2 < d; g2++) {
  1310. const i3 = t8[g2], s7 = t8[g2 + 1], o6 = s7.x - i3.x, l5 = s7.y - i3.y, d2 = Math.sqrt(o6 * o6 + l5 * l5);
  1311. let f3;
  1312. for (; c5 + n6 < x3 + d2; ) {
  1313. c5 += n6;
  1314. const t9 = (c5 - x3) / d2, y2 = b(i3.x, s7.x, t9), m3 = b(i3.y, s7.y, t9);
  1315. void 0 === f3 && (f3 = Math.atan2(l5, o6)), e3.push(new T2(y2, m3, f3, g2, h4));
  1316. }
  1317. x3 += d2;
  1318. }
  1319. }
  1320. static _pushCenterAnchor(e3, t8) {
  1321. let n6 = 0;
  1322. const i2 = t8.length - 1;
  1323. for (let a7 = 0; a7 < i2; a7++)
  1324. n6 += t3.distance(t8[a7], t8[a7 + 1]);
  1325. const s6 = n6 / 2;
  1326. let o5 = 0;
  1327. const l4 = t8.length - 1;
  1328. for (let h4 = 0; h4 < l4; h4++) {
  1329. const n7 = t8[h4], i3 = t8[h4 + 1], l5 = i3.x - n7.x, x3 = i3.y - n7.y, c5 = Math.sqrt(l5 * l5 + x3 * x3);
  1330. if (s6 < o5 + c5) {
  1331. const t9 = (s6 - o5) / c5, d = b(n7.x, i3.x, t9), g2 = b(n7.y, i3.y, t9), f3 = Math.atan2(x3, l5);
  1332. return void e3.push(new T2(d, g2, f3, h4, 0));
  1333. }
  1334. o5 += c5;
  1335. }
  1336. }
  1337. static _deviation(e3, t8, n6) {
  1338. const i2 = (t8.x - e3.x) * (n6.x - t8.x) + (t8.y - e3.y) * (n6.y - t8.y), s6 = (t8.x - e3.x) * (n6.y - t8.y) - (t8.y - e3.y) * (n6.x - t8.x);
  1339. return Math.atan2(s6, i2);
  1340. }
  1341. static _honorsTextMaxAngle(e3, t8, n6, i2, s6) {
  1342. let a7 = 0;
  1343. const o5 = n6 / 2;
  1344. let r8 = new t3(t8.x, t8.y), l4 = t8.segment + 1;
  1345. for (; a7 > -o5; ) {
  1346. if (--l4, l4 < 0)
  1347. return false;
  1348. a7 -= t3.distance(e3[l4], r8), r8 = e3[l4];
  1349. }
  1350. a7 += t3.distance(e3[l4], e3[l4 + 1]);
  1351. const h4 = [];
  1352. let x3 = 0;
  1353. const c5 = e3.length;
  1354. for (; a7 < o5; ) {
  1355. const t9 = e3[l4];
  1356. let n7, o6 = l4;
  1357. do {
  1358. if (++o6, o6 === c5)
  1359. return false;
  1360. n7 = e3[o6];
  1361. } while (n7.isEqual(t9));
  1362. let r9, d = o6;
  1363. do {
  1364. if (++d, d === c5)
  1365. return false;
  1366. r9 = e3[d];
  1367. } while (r9.isEqual(n7));
  1368. const g2 = this._deviation(t9, n7, r9);
  1369. for (h4.push({ deviation: g2, distToAnchor: a7 }), x3 += g2; a7 - h4[0].distToAnchor > s6; )
  1370. x3 -= h4.shift().deviation;
  1371. if (Math.abs(x3) > i2)
  1372. return false;
  1373. a7 += t3.distance(n7, r9), l4 = o6;
  1374. }
  1375. return true;
  1376. }
  1377. static _smoothVertices(e3, t8) {
  1378. if (t8 <= 0)
  1379. return e3;
  1380. let n6 = e3.length;
  1381. if (n6 < 3)
  1382. return e3;
  1383. const i2 = [];
  1384. let s6 = 0, a7 = 0;
  1385. i2.push(0);
  1386. for (let f3 = 1; f3 < n6; f3++) {
  1387. const t9 = t3.distance(e3[f3], e3[f3 - 1]);
  1388. t9 > 0 && (s6 += t9, i2.push(s6), a7++, a7 !== f3 && (e3[a7] = e3[f3]));
  1389. }
  1390. if (n6 = a7 + 1, n6 < 3)
  1391. return e3;
  1392. t8 = Math.min(t8, 0.2 * s6);
  1393. const o5 = e3[0].x, r8 = e3[0].y, l4 = e3[n6 - 1].x, h4 = e3[n6 - 1].y, x3 = t3.sub(e3[0], e3[1]);
  1394. x3.normalize(), e3[0].x += t8 * x3.x, e3[0].y += t8 * x3.y, x3.assignSub(e3[n6 - 1], e3[n6 - 2]), x3.normalize(), e3[n6 - 1].x += t8 * x3.x, e3[n6 - 1].y += t8 * x3.y, i2[0] -= t8, i2[n6 - 1] += t8;
  1395. const c5 = [];
  1396. c5.push(new t3(o5, r8));
  1397. const d = 1e-6, g2 = 0.5 * t8;
  1398. for (let f3 = 1; f3 < n6 - 1; f3++) {
  1399. let s7 = 0, a8 = 0, o6 = 0;
  1400. for (let n7 = f3 - 1; n7 >= 0; n7--) {
  1401. const r9 = g2 + i2[n7 + 1] - i2[f3];
  1402. if (r9 < 0)
  1403. break;
  1404. const l5 = i2[n7 + 1] - i2[n7], h5 = i2[f3] - i2[n7] < g2 ? 1 : r9 / l5;
  1405. if (h5 < d)
  1406. break;
  1407. const x4 = h5 * h5, c6 = h5 * r9 - 0.5 * x4 * l5, y2 = h5 * l5 / t8, m3 = e3[n7 + 1], u4 = e3[n7].x - m3.x, p4 = e3[n7].y - m3.y;
  1408. s7 += y2 / c6 * (m3.x * h5 * r9 + 0.5 * x4 * (r9 * u4 - l5 * m3.x) - x4 * h5 * l5 * u4 / 3), a8 += y2 / c6 * (m3.y * h5 * r9 + 0.5 * x4 * (r9 * p4 - l5 * m3.y) - x4 * h5 * l5 * p4 / 3), o6 += y2;
  1409. }
  1410. for (let r9 = f3 + 1; r9 < n6; r9++) {
  1411. const n7 = g2 - i2[r9 - 1] + i2[f3];
  1412. if (n7 < 0)
  1413. break;
  1414. const l5 = i2[r9] - i2[r9 - 1], h5 = i2[r9] - i2[f3] < g2 ? 1 : n7 / l5;
  1415. if (h5 < d)
  1416. break;
  1417. const x4 = h5 * h5, c6 = h5 * n7 - 0.5 * x4 * l5, y2 = h5 * l5 / t8, m3 = e3[r9 - 1], u4 = e3[r9].x - m3.x, p4 = e3[r9].y - m3.y;
  1418. s7 += y2 / c6 * (m3.x * h5 * n7 + 0.5 * x4 * (n7 * u4 - l5 * m3.x) - x4 * h5 * l5 * u4 / 3), a8 += y2 / c6 * (m3.y * h5 * n7 + 0.5 * x4 * (n7 * p4 - l5 * m3.y) - x4 * h5 * l5 * p4 / 3), o6 += y2;
  1419. }
  1420. c5.push(new t3(s7 / o6, a8 / o6));
  1421. }
  1422. return c5.push(new t3(l4, h4)), e3[0].x = o5, e3[0].y = r8, e3[n6 - 1].x = l4, e3[n6 - 1].y = h4, c5;
  1423. }
  1424. static _pushCentroid(e3, t8) {
  1425. const n6 = 0, i2 = 0, s6 = 4096, a7 = 4096, o5 = t8.length - 1;
  1426. let l4 = 0, h4 = 0, x3 = 0, c5 = t8[0].x, d = t8[0].y;
  1427. c5 > s6 && (c5 = s6), c5 < n6 && (c5 = n6), d > a7 && (d = a7), d < i2 && (d = i2);
  1428. for (let r8 = 1; r8 < o5; r8++) {
  1429. let e4 = t8[r8].x, o6 = t8[r8].y, g2 = t8[r8 + 1].x, f3 = t8[r8 + 1].y;
  1430. e4 > s6 && (e4 = s6), e4 < n6 && (e4 = n6), o6 > a7 && (o6 = a7), o6 < i2 && (o6 = i2), g2 > s6 && (g2 = s6), g2 < n6 && (g2 = n6), f3 > a7 && (f3 = a7), f3 < i2 && (f3 = i2);
  1431. const y2 = (e4 - c5) * (f3 - d) - (g2 - c5) * (o6 - d);
  1432. l4 += y2 * (c5 + e4 + g2), h4 += y2 * (d + o6 + f3), x3 += y2;
  1433. }
  1434. l4 /= 3 * x3, h4 /= 3 * x3, isNaN(l4) || isNaN(h4) || e3.push(new T2(l4, h4));
  1435. }
  1436. };
  1437. A._bidiEngine = new C();
  1438. // node_modules/@arcgis/core/views/2d/tiling/enums.js
  1439. var I4;
  1440. !function(I5) {
  1441. I5[I5.INITIALIZED = 0] = "INITIALIZED", I5[I5.NO_DATA = 1] = "NO_DATA", I5[I5.READY = 2] = "READY", I5[I5.MODIFIED = 3] = "MODIFIED", I5[I5.INVALID = 4] = "INVALID";
  1442. }(I4 || (I4 = {}));
  1443. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/TileParser.js
  1444. var T3 = 8;
  1445. var g = 14;
  1446. var w2 = 5;
  1447. var B = class {
  1448. constructor(t8, r8, s6, i2, o5) {
  1449. if (this._pbfTiles = {}, this._tileClippers = {}, this._client = s6, this._tile = r8, o5) {
  1450. this._styleLayerUIDs = /* @__PURE__ */ new Set();
  1451. for (const e3 of o5)
  1452. this._styleLayerUIDs.add(e3);
  1453. }
  1454. this._styleRepository = i2, this._layers = this._styleRepository.layers;
  1455. const [n6, c5, l4] = r8.tileKey.split("/").map(parseFloat);
  1456. this._level = n6;
  1457. const a7 = T3 + Math.max((this._level - g) * w2, 0);
  1458. for (const u4 of Object.keys(t8)) {
  1459. const r9 = t8[u4];
  1460. this._pbfTiles[u4] = new n(new Uint8Array(r9.protobuff), new DataView(r9.protobuff));
  1461. if (r9.refKey) {
  1462. const [e3] = r9.refKey.split("/").map(parseFloat), t9 = n6 - e3;
  1463. if (t9 > 0) {
  1464. const e4 = (1 << t9) - 1, r10 = c5 & e4, s7 = l4 & e4;
  1465. this._tileClippers[u4] = new n2(t9, r10, s7, 8, a7);
  1466. }
  1467. }
  1468. this._tileClippers[u4] || (this._tileClippers[u4] = new _());
  1469. }
  1470. }
  1471. _canParseStyleLayer(e3) {
  1472. return !this._styleLayerUIDs || this._styleLayerUIDs.has(e3);
  1473. }
  1474. async parse(e3) {
  1475. const t8 = i(), s6 = this._initialize(e3), { returnedBuckets: i2 } = s6;
  1476. this._processLayers(s6), this._linkReferences(s6), this._filterFeatures(s6);
  1477. const o5 = [], n6 = /* @__PURE__ */ new Set(), c5 = (e4, t9) => {
  1478. n6.has(e4) || (o5.push({ name: e4, repeat: t9 }), n6.add(e4));
  1479. }, l4 = {};
  1480. for (const r8 of i2)
  1481. r8.getResources(r8.tileClipper, c5, l4);
  1482. if (this._tile.status === I4.INVALID)
  1483. return [];
  1484. const a7 = this._fetchResources(o5, l4, e3);
  1485. return Promise.all([...a7, t8]).then(() => this._processFeatures(s6.returnedBuckets));
  1486. }
  1487. _initialize(e3) {
  1488. return { signal: e3 && e3.signal, sourceNameToTileData: this._parseTileData(this._pbfTiles), layers: this._layers, zoom: this._level, sourceNameToTileClipper: this._tileClippers, sourceNameToUniqueSourceLayerBuckets: {}, sourceNameToUniqueSourceLayers: {}, returnedBuckets: [], layerIdToBucket: {}, referencerUIDToReferencedId: /* @__PURE__ */ new Map() };
  1489. }
  1490. _processLayers(e3) {
  1491. const { sourceNameToTileData: t8, layers: r8, zoom: s6, sourceNameToTileClipper: i2, sourceNameToUniqueSourceLayerBuckets: o5, sourceNameToUniqueSourceLayers: n6, returnedBuckets: c5, layerIdToBucket: l4, referencerUIDToReferencedId: a7 } = e3;
  1492. for (let u4 = r8.length - 1; u4 >= 0; u4--) {
  1493. const e4 = r8[u4];
  1494. if (!this._canParseStyleLayer(e4.uid) || e4.minzoom && s6 < Math.floor(e4.minzoom) || e4.maxzoom && s6 >= e4.maxzoom || e4.type === a2.BACKGROUND)
  1495. continue;
  1496. if (!t8[e4.source] || !i2[e4.source])
  1497. continue;
  1498. const f3 = t8[e4.source], p4 = i2[e4.source], h4 = e4.sourceLayer, m3 = f3[h4];
  1499. if (m3) {
  1500. let t9 = n6[e4.source];
  1501. if (t9 || (t9 = n6[e4.source] = /* @__PURE__ */ new Set()), t9.add(e4.sourceLayer), e4.refLayerId)
  1502. a7.set(e4.uid, e4.refLayerId);
  1503. else {
  1504. const t10 = this._createBucket(e4);
  1505. if (t10) {
  1506. t10.layerUIDs = [e4.uid], t10.layerExtent = m3.extent, t10.tileClipper = p4;
  1507. let r9 = o5[e4.source];
  1508. r9 || (r9 = o5[e4.source] = {});
  1509. let s7 = r9[h4];
  1510. s7 || (s7 = r9[h4] = []), s7.push(t10), c5.push(t10), l4[e4.id] = t10;
  1511. }
  1512. }
  1513. }
  1514. }
  1515. }
  1516. _linkReferences(e3) {
  1517. const { layerIdToBucket: t8, referencerUIDToReferencedId: r8 } = e3;
  1518. r8.forEach((e4, r9) => {
  1519. t8[e4] && t8[e4].layerUIDs.push(r9);
  1520. });
  1521. }
  1522. _filterFeatures(e3) {
  1523. const { signal: r8, sourceNameToTileData: i2, sourceNameToUniqueSourceLayerBuckets: o5, sourceNameToUniqueSourceLayers: n6 } = e3, c5 = 10 * this._level, l4 = 10 * (this._level + 1), a7 = [], u4 = [];
  1524. for (const t8 of Object.keys(n6)) {
  1525. n6[t8].forEach((e4) => {
  1526. a7.push(e4), u4.push(t8);
  1527. });
  1528. }
  1529. for (let f3 = 0; f3 < a7.length; f3++) {
  1530. const e4 = u4[f3], n7 = a7[f3];
  1531. if (!i2[e4] || !o5[e4])
  1532. continue;
  1533. const p4 = i2[e4][n7], h4 = o5[e4][n7];
  1534. if (!h4 || 0 === h4.length)
  1535. continue;
  1536. if (p(r8))
  1537. return;
  1538. const m3 = p4.getData();
  1539. for (; m3.nextTag(2); ) {
  1540. const e5 = m3.getMessage(), t8 = new s3(e5, p4);
  1541. e5.release();
  1542. const r9 = t8.values;
  1543. if (r9) {
  1544. const e6 = r9._minzoom;
  1545. if (e6 && e6 >= l4)
  1546. continue;
  1547. const t9 = r9._maxzoom;
  1548. if (t9 && t9 <= c5)
  1549. continue;
  1550. }
  1551. for (const s6 of h4)
  1552. s6.pushFeature(t8);
  1553. }
  1554. }
  1555. }
  1556. _fetchResources(e3, t8, r8) {
  1557. const s6 = [], i2 = this._tile.getWorkerTileHandler();
  1558. let o5, n6;
  1559. e3.length > 0 && (o5 = i2.fetchSprites(e3, this._client, r8), s6.push(o5));
  1560. for (const c5 in t8) {
  1561. const e4 = t8[c5];
  1562. e4.size > 0 && (n6 = i2.fetchGlyphs(this._tile.tileKey, c5, e4, this._client, r8), s6.push(n6));
  1563. }
  1564. return s6;
  1565. }
  1566. _processFeatures(e3) {
  1567. const t8 = e3.filter((e4) => e4.hasFeatures() || this._canParseStyleLayer(e4.layer.uid));
  1568. for (const r8 of t8)
  1569. r8.processFeatures(r8.tileClipper);
  1570. return t8;
  1571. }
  1572. _parseTileData(e3) {
  1573. const t8 = {};
  1574. for (const r8 of Object.keys(e3)) {
  1575. const s6 = e3[r8], i2 = {};
  1576. for (; s6.next(); )
  1577. switch (s6.tag()) {
  1578. case 3: {
  1579. const e4 = s6.getMessage(), t9 = new e2(e4);
  1580. e4.release(), i2[t9.name] = t9;
  1581. break;
  1582. }
  1583. default:
  1584. s6.skip();
  1585. }
  1586. t8[r8] = i2;
  1587. }
  1588. return t8;
  1589. }
  1590. _createBucket(e3) {
  1591. switch (e3.type) {
  1592. case a2.BACKGROUND:
  1593. return null;
  1594. case a2.FILL:
  1595. return this._createFillBucket(e3);
  1596. case a2.LINE:
  1597. return this._createLineBucket(e3);
  1598. case a2.CIRCLE:
  1599. return this._createCircleBucket(e3);
  1600. case a2.SYMBOL:
  1601. return this._createSymbolBucket(e3);
  1602. }
  1603. }
  1604. _createFillBucket(e3) {
  1605. return new s4(e3, this._level, this._tile.getWorkerTileHandler().getSpriteItems(), new r5(e3.fillMaterial.getStride()), new r4(), new u3(e3.outlineMaterial.getStride()), new r4());
  1606. }
  1607. _createLineBucket(e3) {
  1608. return new n5(e3, this._level, this._tile.getWorkerTileHandler().getSpriteItems(), new o3(e3.lineMaterial.getStride()), new r4());
  1609. }
  1610. _createCircleBucket(e3) {
  1611. return new r6(e3, this._level, this._tile.getWorkerTileHandler().getSpriteItems(), new a5(e3.circleMaterial.getStride()), new r4());
  1612. }
  1613. _createSymbolBucket(e3) {
  1614. const t8 = this._tile;
  1615. return new A(e3, this._level, new h3(e3.iconMaterial.getStride()), new r4(), new h3(e3.textMaterial.getStride()), new r4(), t8.placementEngine, t8.getWorkerTileHandler());
  1616. }
  1617. };
  1618. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/WorkerTile.js
  1619. var a6 = class {
  1620. constructor(t8, e3, r8, a7) {
  1621. this.status = I4.INITIALIZED, this.placementEngine = new u2(), this.tileKey = t8, this.refKeys = e3, this._workerTileHandler = r8, this._styleRepository = a7;
  1622. }
  1623. release() {
  1624. this.tileKey = "", this.refKeys = null, this.status = I4.INITIALIZED, this._workerTileHandler = null;
  1625. }
  1626. async parse(s6, r8) {
  1627. const a7 = r8 && r8.signal;
  1628. if (r(a7)) {
  1629. const t8 = () => {
  1630. a7.removeEventListener("abort", t8), this.status = I4.INVALID;
  1631. };
  1632. a7.addEventListener("abort", t8);
  1633. }
  1634. let n6;
  1635. const l4 = { bucketsWithData: [], emptyBuckets: null };
  1636. try {
  1637. n6 = await this._parse(s6, r8);
  1638. } catch (y2) {
  1639. if (j(y2))
  1640. throw y2;
  1641. return { result: l4, transferList: [] };
  1642. }
  1643. this.status = I4.READY;
  1644. const o5 = l4.bucketsWithData, u4 = [];
  1645. for (const t8 of n6)
  1646. if (t8.hasFeatures()) {
  1647. const e3 = t8.serialize();
  1648. o5.push(e3);
  1649. } else
  1650. u4.push(t8.layer.uid);
  1651. const h4 = [...o5];
  1652. let c5 = null;
  1653. return u4.length > 0 && (c5 = Uint32Array.from(u4), h4.push(c5.buffer)), l4.emptyBuckets = c5, { result: l4, transferList: h4 };
  1654. }
  1655. setObsolete() {
  1656. this.status = I4.INVALID;
  1657. }
  1658. getLayers() {
  1659. return this._workerTileHandler.getLayers();
  1660. }
  1661. getWorkerTileHandler() {
  1662. return this._workerTileHandler;
  1663. }
  1664. async _parse(t8, e3) {
  1665. const s6 = t8.sourceName2DataAndRefKey;
  1666. if (0 === Object.keys(s6).length)
  1667. return [];
  1668. this.status = I4.MODIFIED;
  1669. return new B(s6, this, e3.client, this._styleRepository, t8.styleLayerUIDs).parse(e3);
  1670. }
  1671. };
  1672. // node_modules/@arcgis/core/views/2d/engine/vectorTiles/WorkerTileHandler.js
  1673. var o4 = class {
  1674. constructor() {
  1675. this._spriteInfo = {}, this._glyphInfo = {};
  1676. }
  1677. reset() {
  1678. return this._spriteInfo = {}, this._glyphInfo = {}, Promise.resolve();
  1679. }
  1680. getLayers() {
  1681. var _a;
  1682. return (_a = this._styleRepository) == null ? void 0 : _a.layers;
  1683. }
  1684. async createTileAndParse(t8, r8) {
  1685. const { key: o5 } = t8, i2 = {};
  1686. for (const e3 of Object.keys(t8.sourceName2DataAndRefKey)) {
  1687. const s6 = t8.sourceName2DataAndRefKey[e3];
  1688. i2[e3] = s6.refKey;
  1689. }
  1690. const n6 = new a6(o5, i2, this, this._styleRepository);
  1691. try {
  1692. return await n6.parse(t8, r8);
  1693. } catch (l4) {
  1694. if (n6.setObsolete(), n6.release(), !j(l4))
  1695. throw l4;
  1696. return null;
  1697. }
  1698. }
  1699. updateStyle(e3) {
  1700. if (!e3 || 0 === e3.length || !this._styleRepository)
  1701. return;
  1702. const s6 = this._styleRepository;
  1703. for (const r8 of e3) {
  1704. const e4 = r8.type, o5 = r8.data;
  1705. switch (e4) {
  1706. case L.PAINTER_CHANGED:
  1707. s6.setPaintProperties(o5.layer, o5.paint);
  1708. break;
  1709. case L.LAYOUT_CHANGED:
  1710. s6.setLayoutProperties(o5.layer, o5.layout);
  1711. break;
  1712. case L.LAYER_REMOVED:
  1713. s6.deleteStyleLayer(o5.layer);
  1714. break;
  1715. case L.LAYER_CHANGED:
  1716. s6.setStyleLayer(o5.layer, o5.index);
  1717. break;
  1718. case L.SPRITES_CHANGED:
  1719. this._spriteInfo = {};
  1720. }
  1721. }
  1722. }
  1723. setStyle(e3) {
  1724. this._styleRepository = new l2(e3), this._spriteInfo = {}, this._glyphInfo = {};
  1725. }
  1726. fetchSprites(e3, t8, s6) {
  1727. const r8 = [], o5 = this._spriteInfo;
  1728. for (const i2 of e3) {
  1729. void 0 === o5[i2.name] && r8.push(i2);
  1730. }
  1731. return 0 === r8.length ? Promise.resolve() : t8.invoke("getSprites", r8, { signal: s6 && s6.signal }).then((e4) => {
  1732. for (const t9 in e4) {
  1733. const s7 = e4[t9];
  1734. o5[t9] = s7;
  1735. }
  1736. });
  1737. }
  1738. getSpriteItems() {
  1739. return this._spriteInfo;
  1740. }
  1741. fetchGlyphs(e3, t8, s6, r8, o5) {
  1742. const i2 = [];
  1743. let n6 = this._glyphInfo[t8];
  1744. return n6 ? s6.forEach((e4) => {
  1745. n6[e4] || i2.push(e4);
  1746. }) : (n6 = this._glyphInfo[t8] = [], s6.forEach((e4) => i2.push(e4))), 0 === i2.length ? Promise.resolve() : r8.invoke("getGlyphs", { tileID: e3, font: t8, codePoints: i2 }, o5).then((e4) => {
  1747. for (let t9 = 0; t9 < e4.length; t9++)
  1748. e4[t9] && (n6[t9] = e4[t9]);
  1749. });
  1750. }
  1751. getGlyphItems(e3) {
  1752. return this._glyphInfo[e3];
  1753. }
  1754. };
  1755. export {
  1756. o4 as default
  1757. };
  1758. //# sourceMappingURL=WorkerTileHandler-53EXBVCL.js.map