FeatureServiceSnappingSourceWorker-ID2DKINZ.js 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. import {
  2. o,
  3. u as u2
  4. } from "./chunk-RDOYANC4.js";
  5. import {
  6. Y
  7. } from "./chunk-FSIQKOJP.js";
  8. import "./chunk-OQSZOHTF.js";
  9. import "./chunk-OP2HNSVZ.js";
  10. import "./chunk-UVQJ7AVD.js";
  11. import "./chunk-DMVKVC5I.js";
  12. import "./chunk-Y7BZ6TKQ.js";
  13. import "./chunk-VEJPYAE4.js";
  14. import "./chunk-4GGDRIJK.js";
  15. import "./chunk-D5UVUJIX.js";
  16. import "./chunk-PZ7XDUL6.js";
  17. import "./chunk-ULSPZIPE.js";
  18. import "./chunk-UMUHMVL4.js";
  19. import "./chunk-FZSI6IGI.js";
  20. import {
  21. S,
  22. c as c4,
  23. f as f3,
  24. x as x2
  25. } from "./chunk-ISHZAVNR.js";
  26. import "./chunk-OXF7W4BJ.js";
  27. import {
  28. a
  29. } from "./chunk-XJHQZ4NT.js";
  30. import "./chunk-CFVLY6NB.js";
  31. import "./chunk-B5O7N7PM.js";
  32. import "./chunk-KOKTANE6.js";
  33. import "./chunk-OKUFE7TO.js";
  34. import {
  35. gt,
  36. it,
  37. lt
  38. } from "./chunk-JKFWEHNK.js";
  39. import "./chunk-IIAN3QNN.js";
  40. import "./chunk-P24XEEHY.js";
  41. import "./chunk-WOXHUQGM.js";
  42. import "./chunk-FMPQIGFA.js";
  43. import "./chunk-EDHROVWI.js";
  44. import "./chunk-3IRT3YKJ.js";
  45. import "./chunk-SAJAEMIJ.js";
  46. import {
  47. v
  48. } from "./chunk-JM5OVQAD.js";
  49. import {
  50. c as c5,
  51. s as s2,
  52. t as t4
  53. } from "./chunk-OJ2HHY2O.js";
  54. import {
  55. x
  56. } from "./chunk-WD4J43GZ.js";
  57. import "./chunk-JOYXMSKE.js";
  58. import {
  59. g
  60. } from "./chunk-SZFMKPVM.js";
  61. import {
  62. c as c3,
  63. d as d2
  64. } from "./chunk-YZVAB3DF.js";
  65. import "./chunk-JLYTER4T.js";
  66. import {
  67. e as e3
  68. } from "./chunk-CRHRHOXH.js";
  69. import "./chunk-JLSNMUQJ.js";
  70. import "./chunk-ECY35CJI.js";
  71. import "./chunk-PT62335L.js";
  72. import "./chunk-JGBXYDGB.js";
  73. import "./chunk-QEWF7QPH.js";
  74. import "./chunk-FNA5GLRW.js";
  75. import "./chunk-MCWCB5IY.js";
  76. import {
  77. U,
  78. j as j2,
  79. l
  80. } from "./chunk-TJV6ODRM.js";
  81. import {
  82. j as j3
  83. } from "./chunk-YLEVJ6UV.js";
  84. import {
  85. t as t3
  86. } from "./chunk-U2WD23Z5.js";
  87. import {
  88. r as r3,
  89. x as x3
  90. } from "./chunk-DUEMJ5XS.js";
  91. import "./chunk-VRLXUHP2.js";
  92. import "./chunk-3LVSQLWJ.js";
  93. import "./chunk-4ONPMX2F.js";
  94. import "./chunk-CRGY2SDS.js";
  95. import "./chunk-4T5ZGMEN.js";
  96. import "./chunk-CZBRZ6SU.js";
  97. import "./chunk-VGWC3IKZ.js";
  98. import {
  99. E,
  100. c as c2,
  101. f as f2,
  102. u,
  103. y as y3
  104. } from "./chunk-2H5MD622.js";
  105. import {
  106. L
  107. } from "./chunk-3RSFVUKZ.js";
  108. import "./chunk-X4SA4ELJ.js";
  109. import "./chunk-5N7JLUJJ.js";
  110. import {
  111. d,
  112. j
  113. } from "./chunk-2ZSOO377.js";
  114. import "./chunk-ZLNEXZAN.js";
  115. import "./chunk-ZYRIJWLX.js";
  116. import "./chunk-RYY6632W.js";
  117. import "./chunk-DW42UVIT.js";
  118. import "./chunk-YAEIHDJH.js";
  119. import "./chunk-TJNOJH33.js";
  120. import "./chunk-OSHI574D.js";
  121. import "./chunk-ETGAZ7LF.js";
  122. import "./chunk-75U5LM2V.js";
  123. import "./chunk-RMDDCMKS.js";
  124. import "./chunk-VCH45Q2I.js";
  125. import "./chunk-GSSTTHIT.js";
  126. import {
  127. n as n3
  128. } from "./chunk-IM3LVQXV.js";
  129. import "./chunk-HZRKBTHJ.js";
  130. import "./chunk-DVUG3KID.js";
  131. import "./chunk-FWSQEIAR.js";
  132. import "./chunk-VEGAOVMY.js";
  133. import {
  134. w2
  135. } from "./chunk-6T6G6LCQ.js";
  136. import "./chunk-YEJL5NEF.js";
  137. import {
  138. k2 as k
  139. } from "./chunk-PQFTYGF5.js";
  140. import {
  141. e,
  142. m,
  143. n2 as n,
  144. n5 as n2,
  145. t2,
  146. y3 as y2
  147. } from "./chunk-2Z2TG5CU.js";
  148. import "./chunk-6KZ2LTDA.js";
  149. import "./chunk-U2XHEJM7.js";
  150. import {
  151. r as r2
  152. } from "./chunk-SQOPWYIT.js";
  153. import {
  154. A,
  155. f,
  156. w
  157. } from "./chunk-V6P2MAQQ.js";
  158. import {
  159. s2 as s
  160. } from "./chunk-E5O6P5I2.js";
  161. import {
  162. c,
  163. y
  164. } from "./chunk-SPWQ3AWG.js";
  165. import {
  166. i
  167. } from "./chunk-2TIUKVZN.js";
  168. import {
  169. e as e2,
  170. r,
  171. t
  172. } from "./chunk-YXWMMD76.js";
  173. import "./chunk-S5KM4IGW.js";
  174. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js
  175. function r4(e5 = false, t7) {
  176. if (e5) {
  177. const { elevationInfo: e6, alignPointsInFeatures: s4, spatialReference: n6 } = t7;
  178. return new l2(e6, s4, n6);
  179. }
  180. return new c6();
  181. }
  182. var c6 = class {
  183. async alignCandidates(e5, t7) {
  184. return e5;
  185. }
  186. notifyElevationSourceChange() {
  187. }
  188. };
  189. var h = 1024;
  190. var l2 = class {
  191. constructor(t7, s4, n6) {
  192. this._elevationInfo = t7, this._alignPointsInFeatures = s4, this.spatialReference = n6, this._alignmentsCache = new e3(h), this._cacheVersion = 0, this._metersPerVerticalUnit = L(n6);
  193. }
  194. async alignCandidates(e5, t7) {
  195. const n6 = this._elevationInfo;
  196. return r(n6) && "absolute-height" === n6.mode && !n6.featureExpressionInfo ? (this._alignAbsoluteElevationCandidates(e5, n6), e5) : this._alignComputedElevationCandidates(e5, t7);
  197. }
  198. notifyElevationSourceChange() {
  199. this._alignmentsCache.clear(), this._cacheVersion++;
  200. }
  201. _alignAbsoluteElevationCandidates(e5, t7) {
  202. const { offset: s4, unit: o4 } = t7;
  203. if (t(s4))
  204. return;
  205. const i4 = s4 * (r3(o4 != null ? o4 : "meters") / this._metersPerVerticalUnit);
  206. for (const n6 of e5)
  207. switch (n6.type) {
  208. case "edge":
  209. n6.start.z += i4, n6.end.z += i4;
  210. continue;
  211. case "vertex":
  212. n6.target.z += i4;
  213. continue;
  214. }
  215. }
  216. async _alignComputedElevationCandidates(e5, s4) {
  217. const n6 = /* @__PURE__ */ new Map();
  218. for (const o4 of e5)
  219. r2(n6, o4.objectId, p).push(o4);
  220. const [i4, a4, r8] = this._prepareQuery(n6), c9 = await this._alignPointsInFeatures(i4, s4);
  221. f(s4);
  222. if (r8 !== this._cacheVersion)
  223. return this._alignComputedElevationCandidates(e5, s4);
  224. this._applyCacheAndResponse(i4, c9, a4);
  225. const { drapedObjectIds: h2, failedObjectIds: l3 } = c9, d4 = [];
  226. for (const t7 of e5) {
  227. const { objectId: e6 } = t7;
  228. h2.has(e6) && "edge" === t7.type && (t7.draped = true), l3.has(e6) || d4.push(t7);
  229. }
  230. return d4;
  231. }
  232. _prepareQuery(e5) {
  233. const t7 = [], s4 = [];
  234. for (const [n6, o4] of e5) {
  235. const e6 = [];
  236. for (const t8 of o4)
  237. this._addToQueriesOrCachedResult(n6, t8.target, e6, s4), "edge" === t8.type && (this._addToQueriesOrCachedResult(n6, t8.start, e6, s4), this._addToQueriesOrCachedResult(n6, t8.end, e6, s4));
  238. 0 !== e6.length && t7.push({ objectId: n6, points: e6 });
  239. }
  240. return [t7, s4, this._cacheVersion];
  241. }
  242. _addToQueriesOrCachedResult(e5, t7, n6, o4) {
  243. const i4 = u3(e5, t7), a4 = this._alignmentsCache.get(i4);
  244. r(a4) ? o4.push(new d3(t7, a4)) : n6.push(t7);
  245. }
  246. _applyCacheAndResponse(e5, { elevations: t7, drapedObjectIds: s4, failedObjectIds: n6 }, o4) {
  247. for (const r8 of o4)
  248. r8.apply();
  249. let i4 = 0;
  250. const a4 = this._alignmentsCache;
  251. for (const { objectId: r8, points: c9 } of e5) {
  252. if (n6.has(r8)) {
  253. i4 += c9.length;
  254. continue;
  255. }
  256. const e6 = !s4.has(r8);
  257. for (const s5 of c9) {
  258. const n7 = u3(r8, s5), o5 = t7[i4++];
  259. s5.z = o5, e6 && a4.put(n7, o5, 1);
  260. }
  261. }
  262. }
  263. };
  264. var d3 = class {
  265. constructor(e5, t7) {
  266. this.point = e5, this.z = t7;
  267. }
  268. apply() {
  269. this.point.z = this.z;
  270. }
  271. };
  272. function u3(e5, { x: t7, y: s4, z: n6 }) {
  273. return `${e5}-${t7}-${s4}-${n6 != null ? n6 : 0}}`;
  274. }
  275. function p() {
  276. return [];
  277. }
  278. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/snappingCandidateElevationFilter.js
  279. var t5 = class {
  280. filter(t7, n6) {
  281. return n6;
  282. }
  283. notifyElevationSourceChange() {
  284. }
  285. };
  286. var n4 = class {
  287. filter(t7, n6) {
  288. const { point: r8, distance: c9 } = t7, { z: i4 } = r8;
  289. if (!(null != i4))
  290. return n6;
  291. if (0 === n6.length)
  292. return n6;
  293. const o4 = s3(c9), u5 = this._updateCandidatesTo3D(n6, r8, o4).filter(e4);
  294. return u5.sort(a2), u5;
  295. }
  296. _updateCandidatesTo3D(t7, n6, e5) {
  297. for (const r8 of t7)
  298. switch (r8.type) {
  299. case "edge":
  300. c7(r8, n6, e5);
  301. continue;
  302. case "vertex":
  303. o2(r8, n6, e5);
  304. continue;
  305. }
  306. return t7;
  307. }
  308. };
  309. function e4(t7) {
  310. return t7.distance <= 1;
  311. }
  312. function r5(e5 = false) {
  313. return e5 ? new n4() : new t5();
  314. }
  315. function c7(t7, n6, { x: e5, y: r8, z: c9 }) {
  316. const { start: o4, end: s4, target: a4 } = t7;
  317. t7.draped || i2(a4, n6, o4, s4);
  318. const u5 = (n6.x - a4.x) / e5, d4 = (n6.y - a4.y) / r8, f4 = (n6.z - a4.z) / c9;
  319. t7.distance = Math.sqrt(u5 * u5 + d4 * d4 + f4 * f4);
  320. }
  321. function i2(t7, n6, e5, r8) {
  322. const c9 = r8.x - e5.x, i4 = r8.y - e5.y, o4 = r8.z - e5.z, s4 = c9 * c9 + i4 * i4 + o4 * o4, a4 = (n6.x - e5.x) * c9 + (n6.y - e5.y) * i4 + o4 * (n6.z - e5.z), u5 = Math.min(1, Math.max(0, a4 / s4)), d4 = e5.x + c9 * u5, f4 = e5.y + i4 * u5, x6 = e5.z + o4 * u5;
  323. t7.x = d4, t7.y = f4, t7.z = x6;
  324. }
  325. function o2(t7, n6, { x: e5, y: r8, z: c9 }) {
  326. const { target: i4 } = t7, o4 = (n6.x - i4.x) / e5, s4 = (n6.y - i4.y) / r8, a4 = (n6.z - i4.z) / c9, u5 = Math.sqrt(o4 * o4 + s4 * s4 + a4 * a4);
  327. t7.distance = u5;
  328. }
  329. function s3(t7) {
  330. return "number" == typeof t7 ? { x: t7, y: t7, z: t7 } : t7;
  331. }
  332. function a2(t7, n6) {
  333. return t7.distance - n6.distance;
  334. }
  335. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/symbologySnappingCandidates.js
  336. function n5(t7 = false, e5) {
  337. return t7 ? new i3(e5) : new c8();
  338. }
  339. var c8 = class {
  340. async fetch() {
  341. return [];
  342. }
  343. notifySymbologyChange() {
  344. }
  345. };
  346. var r6 = 1024;
  347. var i3 = class {
  348. constructor(t7) {
  349. this._getSymbologyCandidates = t7, this._candidatesCache = new e3(r6), this._cacheVersion = 0;
  350. }
  351. async fetch(e5, o4) {
  352. if (0 === e5.length)
  353. return [];
  354. const n6 = [], c9 = [], r8 = this._candidatesCache;
  355. for (const s4 of e5) {
  356. const e6 = a3(s4), o5 = r8.get(e6);
  357. if (o5)
  358. for (const s5 of o5)
  359. c9.push(y(s5));
  360. else
  361. n6.push(s4), r8.put(e6, [], 1);
  362. }
  363. if (0 === n6.length)
  364. return c9;
  365. const i4 = this._cacheVersion, { candidates: h2, sourceCandidateIndices: d4 } = await this._getSymbologyCandidates(n6, o4);
  366. f(o4);
  367. if (i4 !== this._cacheVersion)
  368. return this.fetch(e5, o4);
  369. const f4 = [], { length: g2 } = h2;
  370. for (let s4 = 0; s4 < g2; ++s4) {
  371. const e6 = h2[s4], o5 = a3(n6[d4[s4]]), c10 = r8.get(o5);
  372. c10.push(e6), r8.put(o5, c10, c10.length), f4.push(y(e6));
  373. }
  374. return c9.concat(f4);
  375. }
  376. notifySymbologyChange() {
  377. this._candidatesCache.clear(), this._cacheVersion++;
  378. }
  379. };
  380. function a3(t7) {
  381. var _a, _b, _c;
  382. switch (t7.type) {
  383. case "vertex": {
  384. const { objectId: e5, target: s4 } = t7, n6 = `${e5}-vertex-${s4.x}-${s4.y}-${(_a = s4.z) != null ? _a : 0}`;
  385. return c(n6).toString();
  386. }
  387. case "edge": {
  388. const { objectId: e5, start: s4, end: n6 } = t7, c9 = `${e5}-edge-${s4.x}-${s4.y}-${(_b = s4.z) != null ? _b : 0}-to-${n6.x}-${n6.y}-${(_c = n6.z) != null ? _c : 0}`;
  389. return c(c9).toString();
  390. }
  391. default:
  392. return "";
  393. }
  394. }
  395. // node_modules/@arcgis/core/core/AsyncSequence.js
  396. var r7 = class extends m {
  397. constructor() {
  398. super(...arguments), this.updating = false, this._pending = [];
  399. }
  400. push(s4, t7) {
  401. this._pending.push({ promise: s4, callback: t7 }), 1 === this._pending.length && this._process();
  402. }
  403. _process() {
  404. if (!this._pending.length)
  405. return void (this.updating = false);
  406. this.updating = true;
  407. const s4 = this._pending[0];
  408. s4.promise.then((t7) => s4.callback(t7)).catch(() => {
  409. }).then(() => {
  410. this._pending.shift(), this._process();
  411. });
  412. }
  413. };
  414. e([y2()], r7.prototype, "updating", void 0), r7 = e([n2("esri.core.AsyncSequence")], r7);
  415. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/PendingFeatureTile.js
  416. var o3 = class {
  417. constructor(t7, e5) {
  418. this.data = t7, this.resolution = e5, this.state = { type: u4.CREATED }, this.alive = true;
  419. }
  420. process(t7) {
  421. switch (this.state.type) {
  422. case u4.CREATED:
  423. return this.state = this._gotoFetchCount(this.state, t7), this.state.task.promise.then(t7.resume, t7.resume);
  424. case u4.FETCH_COUNT:
  425. break;
  426. case u4.FETCHED_COUNT:
  427. return this.state = this._gotoFetchFeatures(this.state, t7), this.state.task.promise.then(t7.resume, t7.resume);
  428. case u4.FETCH_FEATURES:
  429. break;
  430. case u4.FETCHED_FEATURES:
  431. this.state = this._goToDone(this.state, t7);
  432. case u4.DONE:
  433. }
  434. return null;
  435. }
  436. get debugInfo() {
  437. return { data: this.data, featureCount: this._featureCount, state: this._stateToString };
  438. }
  439. get _featureCount() {
  440. switch (this.state.type) {
  441. case u4.CREATED:
  442. case u4.FETCH_COUNT:
  443. return 0;
  444. case u4.FETCHED_COUNT:
  445. return this.state.featureCount;
  446. case u4.FETCH_FEATURES:
  447. return this.state.previous.featureCount;
  448. case u4.FETCHED_FEATURES:
  449. return this.state.features.length;
  450. case u4.DONE:
  451. return this.state.previous.features.length;
  452. }
  453. }
  454. get _stateToString() {
  455. switch (this.state.type) {
  456. case u4.CREATED:
  457. return "created";
  458. case u4.FETCH_COUNT:
  459. return "fetch-count";
  460. case u4.FETCHED_COUNT:
  461. return "fetched-count";
  462. case u4.FETCH_FEATURES:
  463. return "fetch-features";
  464. case u4.FETCHED_FEATURES:
  465. return "fetched-features";
  466. case u4.DONE:
  467. return "done";
  468. }
  469. }
  470. _gotoFetchCount(s4, a4) {
  471. return { type: u4.FETCH_COUNT, previous: s4, task: j(async (t7) => {
  472. const s5 = await d(a4.fetchCount(this, t7));
  473. this.state.type === u4.FETCH_COUNT && (this.state = this._gotoFetchedCount(this.state, s5.ok ? s5.value : 1 / 0));
  474. }) };
  475. }
  476. _gotoFetchedCount(t7, e5) {
  477. return { type: u4.FETCHED_COUNT, featureCount: e5, previous: t7 };
  478. }
  479. _gotoFetchFeatures(s4, a4) {
  480. return { type: u4.FETCH_FEATURES, previous: s4, task: j(async (t7) => {
  481. const r8 = await d(a4.fetchFeatures(this, s4.featureCount, t7));
  482. this.state.type === u4.FETCH_FEATURES && (this.state = this._gotoFetchedFeatures(this.state, r8.ok ? r8.value : []));
  483. }) };
  484. }
  485. _gotoFetchedFeatures(t7, e5) {
  486. return { type: u4.FETCHED_FEATURES, previous: t7, features: e5 };
  487. }
  488. _goToDone(t7, e5) {
  489. return e5.finish(this, t7.features), { type: u4.DONE, previous: t7 };
  490. }
  491. reset() {
  492. const t7 = this.state;
  493. switch (this.state = { type: u4.CREATED }, t7.type) {
  494. case u4.CREATED:
  495. case u4.FETCHED_COUNT:
  496. case u4.FETCHED_FEATURES:
  497. case u4.DONE:
  498. break;
  499. case u4.FETCH_COUNT:
  500. case u4.FETCH_FEATURES:
  501. t7.task.abort();
  502. }
  503. }
  504. intersects(t7) {
  505. return !(!t(t7) && this.data.extent) || (c2(t7, T), E(this.data.extent, T));
  506. }
  507. };
  508. var u4;
  509. !function(t7) {
  510. t7[t7.CREATED = 0] = "CREATED", t7[t7.FETCH_COUNT = 1] = "FETCH_COUNT", t7[t7.FETCHED_COUNT = 2] = "FETCHED_COUNT", t7[t7.FETCH_FEATURES = 3] = "FETCH_FEATURES", t7[t7.FETCHED_FEATURES = 4] = "FETCHED_FEATURES", t7[t7.DONE = 5] = "DONE";
  511. }(u4 || (u4 = {}));
  512. var T = u();
  513. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js
  514. var C = class extends d2 {
  515. constructor(e5) {
  516. super(e5), this.tilesOfInterest = [], this.availability = 0, this._pendingTiles = /* @__PURE__ */ new Map(), this._pendingEdits = new r7(), this._pendingEditsAbortController = new AbortController();
  517. }
  518. get _minimumVerticesPerFeature() {
  519. var _a;
  520. switch ((_a = this.store) == null ? void 0 : _a.featureStore.geometryType) {
  521. case "esriGeometryPoint":
  522. case "esriGeometryMultipoint":
  523. return 1;
  524. case "esriGeometryPolygon":
  525. return 4;
  526. case "esriGeometryPolyline":
  527. return 2;
  528. }
  529. }
  530. set filter(e5) {
  531. const t7 = this._get("filter"), i4 = this._filterProperties(e5);
  532. JSON.stringify(t7) !== JSON.stringify(i4) && this._set("filter", i4);
  533. }
  534. set customParameters(e5) {
  535. const t7 = this._get("customParameters");
  536. JSON.stringify(t7) !== JSON.stringify(e5) && this._set("customParameters", e5);
  537. }
  538. get _configuration() {
  539. return { filter: this.filter, customParameters: this.customParameters, tileInfo: this.tileInfo, tileSize: this.tileSize };
  540. }
  541. set tileInfo(e5) {
  542. const t7 = this._get("tileInfo");
  543. t7 !== e5 && (r(e5) && r(t7) && JSON.stringify(e5) === JSON.stringify(t7) || (this._set("tileInfo", e5), this.store.tileInfo = e5));
  544. }
  545. set tileSize(e5) {
  546. this._get("tileSize") !== e5 && this._set("tileSize", e5);
  547. }
  548. get updating() {
  549. return this.updatingExcludingEdits || this._pendingEdits.updating;
  550. }
  551. get updatingExcludingEdits() {
  552. return this.updatingHandles.updating;
  553. }
  554. get hasZ() {
  555. return this.store.featureStore.hasZ;
  556. }
  557. initialize() {
  558. this._initializeFetchExtent(), this.updatingHandles.add(() => this._configuration, () => this.refresh()), this.updatingHandles.add(() => this.tilesOfInterest, (e5, i4) => {
  559. i(e5, i4, ({ id: e6 }, { id: t7 }) => e6 === t7) || this._process();
  560. }, U);
  561. }
  562. destroy() {
  563. this._pendingTiles.forEach((e5) => this._deletePendingTile(e5)), this._pendingTiles.clear(), this.store.destroy(), this.tilesOfInterest.length = 0, this._pendingEditsAbortController.abort(), this._pendingEditsAbortController = null;
  564. }
  565. refresh() {
  566. this.store.refresh(), this._pendingTiles.forEach((e5) => this._deletePendingTile(e5)), this._process();
  567. }
  568. applyEdits(e5) {
  569. this._pendingEdits.push(e5, async (e6) => {
  570. if (0 === e6.addedFeatures.length && 0 === e6.updatedFeatures.length && 0 === e6.deletedFeatures.length)
  571. return;
  572. for (const [, i4] of this._pendingTiles)
  573. i4.reset();
  574. const t7 = { ...e6, deletedFeatures: e6.deletedFeatures.map(({ objectId: e7, globalId: t8 }) => e7 && -1 !== e7 ? e7 : this._lookupObjectIdByGlobalId(t8)) };
  575. await this.updatingHandles.addPromise(this.store.processEdits(t7, (e7, t8) => this._queryFeaturesById(e7, t8), this._pendingEditsAbortController.signal)), this._processPendingTiles();
  576. });
  577. }
  578. _initializeFetchExtent() {
  579. if (!this.capabilities.query.supportsExtent || !g(this.url))
  580. return;
  581. const e5 = j(async (e6) => {
  582. var _a;
  583. try {
  584. const t7 = await x2(this.url, new x({ where: "1=1", outSpatialReference: this.spatialReference, cacheHint: !!this.capabilities.query.supportsCacheHint || void 0 }), { query: this._configuration.customParameters, signal: e6 });
  585. this.store.extent = w2.fromJSON((_a = t7.data) == null ? void 0 : _a.extent);
  586. } catch (t7) {
  587. w(t7), s.getLogger(this.declaredClass).warn("Failed to fetch data extent", t7);
  588. }
  589. });
  590. this.updatingHandles.addPromise(e5.promise.then(() => this._process())), this.handles.add(n(() => e5.abort()));
  591. }
  592. get debugInfo() {
  593. return { numberOfFeatures: this.store.featureStore.numFeatures, tilesOfInterest: this.tilesOfInterest, pendingTiles: Array.from(this._pendingTiles.values()).map((e5) => e5.debugInfo), storedTiles: this.store.debugInfo };
  594. }
  595. _process() {
  596. this._markTilesNotAlive(), this._createPendingTiles(), this._deletePendingTiles(), this._processPendingTiles();
  597. }
  598. _markTilesNotAlive() {
  599. for (const [, e5] of this._pendingTiles)
  600. e5.alive = false;
  601. }
  602. _createPendingTiles() {
  603. const e5 = this._collectMissingTilesInfo();
  604. if (this._setAvailability(t(e5) ? 1 : e5.coveredArea / e5.fullArea), !t(e5))
  605. for (const { data: t7, resolution: i4 } of e5.missingTiles) {
  606. const e6 = this._pendingTiles.get(t7.id);
  607. e6 ? (e6.resolution = i4, e6.alive = true) : this._createPendingTile(t7, i4);
  608. }
  609. }
  610. _collectMissingTilesInfo() {
  611. let e5 = null;
  612. for (let t7 = this.tilesOfInterest.length - 1; t7 >= 0; t7--) {
  613. const i4 = this.tilesOfInterest[t7], s4 = this.store.process(i4, (e6, t8) => this._verifyTileComplexity(e6, t8));
  614. t(e5) ? e5 = s4 : e5.prepend(s4);
  615. }
  616. return e5;
  617. }
  618. _deletePendingTiles() {
  619. for (const [, e5] of this._pendingTiles)
  620. e5.alive || this._deletePendingTile(e5);
  621. }
  622. _processPendingTiles() {
  623. const e5 = { fetchCount: (e6, t7) => this._fetchCount(e6, t7), fetchFeatures: (e6, t7, i4) => this._fetchFeatures(e6, t7, i4), finish: (e6, t7) => this._finishPendingTile(e6, t7), resume: () => this._processPendingTiles() };
  624. if (this._ensureFetchAllCounts(e5))
  625. for (const [, t7] of this._pendingTiles)
  626. this._verifyTileComplexity(this.store.getFeatureCount(t7.data), t7.resolution) && this.updatingHandles.addPromise(t7.process(e5));
  627. }
  628. _verifyTileComplexity(e5, t7) {
  629. return this._verifyVertexComplexity(e5) && this._verifyFeatureDensity(e5, t7);
  630. }
  631. _verifyVertexComplexity(e5) {
  632. return e5 * this._minimumVerticesPerFeature < x4;
  633. }
  634. _verifyFeatureDensity(e5, t7) {
  635. if (t(this.tileInfo))
  636. return false;
  637. const i4 = this.tileSize * t7;
  638. return e5 * (j4 / (i4 * i4)) < w3;
  639. }
  640. _ensureFetchAllCounts(e5) {
  641. let t7 = true;
  642. for (const [, i4] of this._pendingTiles)
  643. i4.state.type < u4.FETCHED_COUNT && this.updatingHandles.addPromise(i4.process(e5)), i4.state.type <= u4.FETCH_COUNT && (t7 = false);
  644. return t7;
  645. }
  646. _finishPendingTile(e5, t7) {
  647. this.store.add(e5.data, t7), this._deletePendingTile(e5), this._updateAvailability();
  648. }
  649. _updateAvailability() {
  650. const e5 = this._collectMissingTilesInfo();
  651. this._setAvailability(t(e5) ? 1 : e5.coveredArea / e5.fullArea);
  652. }
  653. _setAvailability(e5) {
  654. this._set("availability", e5);
  655. }
  656. _createPendingTile(e5, t7) {
  657. const i4 = new o3(e5, t7);
  658. return this._pendingTiles.set(e5.id, i4), i4;
  659. }
  660. _deletePendingTile(e5) {
  661. e5.reset(), this._pendingTiles.delete(e5.data.id);
  662. }
  663. async _fetchCount(e5, t7) {
  664. return this.store.fetchCount(e5.data, this.url, this._createCountQuery(e5), { query: this.customParameters, timeout: S2, signal: t7 });
  665. }
  666. async _fetchFeatures(e5, t7, i4) {
  667. let s4, r8 = 0, o4 = 0, n6 = t7;
  668. for (; ; ) {
  669. const a4 = this._createFeaturesQuery(e5), l3 = this._setPagingParameters(a4, r8, n6), { features: c9, exceededTransferLimit: d4 } = await this._queryFeatures(a4, i4);
  670. if (l3 && (r8 += e2(a4.num)), o4 += c9.length, s4 = s4 ? s4.concat(c9) : c9, n6 = t7 - o4, !l3 || !d4 || n6 <= 0)
  671. return s4;
  672. }
  673. }
  674. _filterProperties(e5) {
  675. return t(e5) ? { where: "1=1", gdbVersion: void 0, timeExtent: void 0 } : { where: e5.where || "1=1", timeExtent: e5.timeExtent, gdbVersion: e5.gdbVersion };
  676. }
  677. _lookupObjectIdByGlobalId(e5) {
  678. const t7 = this.globalIdField, i4 = this.objectIdField;
  679. if (t(t7))
  680. throw new Error("Expected globalIdField to be defined");
  681. let s4 = null;
  682. if (this.store.featureStore.forEach((r8) => {
  683. var _a;
  684. e5 === r8.attributes[t7] && (s4 = (_a = r8.objectId) != null ? _a : r8.attributes[i4]);
  685. }), t(s4))
  686. throw new Error(`Expected to find a feature with globalId ${e5}`);
  687. return s4;
  688. }
  689. _queryFeaturesById(e5, t7) {
  690. const i4 = this._createFeaturesQuery();
  691. return i4.objectIds = e5, this._queryFeatures(i4, t7);
  692. }
  693. _queryFeatures(e5, t7) {
  694. return this.capabilities.query.supportsFormatPBF ? this._queryFeaturesPBF(e5, t7) : this._queryFeaturesJSON(e5, t7);
  695. }
  696. async _queryFeaturesPBF(e5, t7) {
  697. const { sourceSpatialReference: i4 } = this, { data: s4 } = await f3(this.url, e5, new a({ sourceSpatialReference: i4 }), { query: this._configuration.customParameters, timeout: S2, signal: t7 });
  698. return it(s4);
  699. }
  700. async _queryFeaturesJSON(e5, t7) {
  701. const { sourceSpatialReference: i4 } = this, { data: s4 } = await c4(this.url, e5, i4, { query: this._configuration.customParameters, timeout: S2, signal: t7 });
  702. return lt(s4, this.objectIdField);
  703. }
  704. _createCountQuery(e5) {
  705. const t7 = this._createBaseQuery(e5);
  706. return this.capabilities.query.supportsCacheHint && (t7.cacheHint = true), t7;
  707. }
  708. _createFeaturesQuery(e5 = null) {
  709. const t7 = this._createBaseQuery(e5);
  710. return t7.outFields = this.globalIdField ? [this.globalIdField, this.objectIdField] : [this.objectIdField], t7.returnGeometry = true, r(e5) && (this.capabilities.query.supportsResultType ? t7.resultType = "tile" : this.capabilities.query.supportsCacheHint && (t7.cacheHint = true)), t7;
  711. }
  712. _createBaseQuery(e5) {
  713. const t7 = new x({ returnZ: this.hasZ, returnM: false, geometry: r(this.tileInfo) && r(e5) ? f2(e5.data.extent, this.tileInfo.spatialReference) : void 0 }), i4 = this._configuration.filter;
  714. return r(i4) && (t7.where = i4.where, t7.gdbVersion = i4.gdbVersion, t7.timeExtent = i4.timeExtent), t7.outSpatialReference = this.spatialReference, t7;
  715. }
  716. _setPagingParameters(e5, t7, i4) {
  717. if (!this.capabilities.query.supportsPagination)
  718. return false;
  719. const { supportsMaxRecordCountFactor: s4, supportsCacheHint: r8, tileMaxRecordCount: o4, maxRecordCount: n6, supportsResultType: a4 } = this.capabilities.query, l3 = s4 ? x.MAX_MAX_RECORD_COUNT_FACTOR : 1, u5 = l3 * ((a4 || r8) && o4 ? o4 : n6 || E2);
  720. return e5.start = t7, s4 ? (e5.maxRecordCountFactor = Math.min(l3, Math.ceil(i4 / u5)), e5.num = Math.min(i4, e5.maxRecordCountFactor * u5)) : e5.num = Math.min(i4, u5), true;
  721. }
  722. };
  723. e([y2({ constructOnly: true })], C.prototype, "url", void 0), e([y2({ constructOnly: true })], C.prototype, "objectIdField", void 0), e([y2({ constructOnly: true })], C.prototype, "globalIdField", void 0), e([y2({ constructOnly: true })], C.prototype, "capabilities", void 0), e([y2({ constructOnly: true })], C.prototype, "sourceSpatialReference", void 0), e([y2({ constructOnly: true })], C.prototype, "spatialReference", void 0), e([y2({ constructOnly: true })], C.prototype, "store", void 0), e([y2({ readOnly: true })], C.prototype, "_minimumVerticesPerFeature", null), e([y2()], C.prototype, "filter", null), e([y2()], C.prototype, "customParameters", null), e([y2({ readOnly: true })], C.prototype, "_configuration", null), e([y2()], C.prototype, "tileInfo", null), e([y2()], C.prototype, "tileSize", null), e([y2()], C.prototype, "tilesOfInterest", void 0), e([y2({ readOnly: true })], C.prototype, "updating", null), e([y2({ readOnly: true })], C.prototype, "updatingExcludingEdits", null), e([y2({ readOnly: true })], C.prototype, "availability", void 0), e([y2()], C.prototype, "hasZ", null), C = e([n2("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")], C);
  724. var E2 = 2e3;
  725. var S2 = 6e5;
  726. var x4 = 1e6;
  727. var j4 = 25;
  728. var w3 = 1;
  729. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileCache.js
  730. var t6 = class {
  731. constructor() {
  732. this._store = /* @__PURE__ */ new Map(), this._byteSize = 0;
  733. }
  734. set(t7, e5) {
  735. this.delete(t7), this._store.set(t7, e5), this._byteSize += e5.byteSize;
  736. }
  737. delete(t7) {
  738. const e5 = this._store.get(t7);
  739. return !!this._store.delete(t7) && (null != e5 && (this._byteSize -= e5.byteSize), true);
  740. }
  741. get(t7) {
  742. return this._used(t7), this._store.get(t7);
  743. }
  744. has(t7) {
  745. return this._used(t7), this._store.has(t7);
  746. }
  747. clear() {
  748. this._store.clear();
  749. }
  750. applyByteSizeLimit(t7, e5) {
  751. for (const [s4, r8] of this._store) {
  752. if (this._byteSize <= t7)
  753. break;
  754. this.delete(s4), e5(r8);
  755. }
  756. }
  757. values() {
  758. return this._store.values();
  759. }
  760. [Symbol.iterator]() {
  761. return this._store[Symbol.iterator]();
  762. }
  763. _used(t7) {
  764. const e5 = this._store.get(t7);
  765. e5 && (this._store.delete(t7), this._store.set(t7, e5));
  766. }
  767. };
  768. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js
  769. var v2 = class extends m {
  770. constructor(e5) {
  771. super(e5), this.tileInfo = null, this.extent = null, this.maximumByteSize = 10 * s2.MEGABYTES, this._tileBounds = new o(), this._tiles = new t6(), this._refCounts = /* @__PURE__ */ new Map(), this._tileFeatureCounts = /* @__PURE__ */ new Map(), this._tmpBoundingRect = u();
  772. }
  773. add(e5, t7) {
  774. const s4 = [];
  775. for (const i4 of t7)
  776. this._referenceFeature(i4.objectId) === x5.ADDED && s4.push(i4);
  777. this._addTileStorage(e5, new Set(t7.map(({ objectId: e6 }) => e6)), C2(t7)), this.featureStore.addMany(s4), this._tiles.applyByteSizeLimit(this.maximumByteSize, (e6) => this._removeTileStorage(e6));
  778. }
  779. destroy() {
  780. this.clear(), this._tileFeatureCounts.clear();
  781. }
  782. clear() {
  783. this.featureStore.clear(), this._tileBounds.clear(), this._tiles.clear(), this._refCounts.clear();
  784. }
  785. refresh() {
  786. this.clear(), this._tileFeatureCounts.clear();
  787. }
  788. processEdits(e5, t7, s4) {
  789. return this._processEditsDelete(e5.deletedFeatures.concat(e5.updatedFeatures)), this._processEditsRefetch(e5.addedFeatures.concat(e5.updatedFeatures), t7, s4);
  790. }
  791. _addTileStorage(e5, t7, s4) {
  792. this._tiles.set(e5.id, new T2(e5, t7, s4)), this._tileBounds.set(e5.id, e5.extent), this._tileFeatureCounts.set(e5.id, t7.size);
  793. }
  794. _remove({ id: e5 }) {
  795. const t7 = this._tiles.get(e5);
  796. t7 && this._removeTileStorage(t7);
  797. }
  798. _removeTileStorage(e5) {
  799. const t7 = [];
  800. for (const i4 of e5.objectIds)
  801. this._unreferenceFeature(i4) === x5.REMOVED && t7.push(i4);
  802. this.featureStore.removeManyById(t7);
  803. const s4 = e5.data.id;
  804. this._tiles.delete(s4), this._tileBounds.delete(s4);
  805. }
  806. _processEditsDelete(e5) {
  807. this.featureStore.removeManyById(e5);
  808. for (const [, t7] of this._tiles) {
  809. for (const s4 of e5)
  810. t7.objectIds.delete(s4);
  811. this._tileFeatureCounts.set(t7.data.id, t7.objectIds.size);
  812. }
  813. for (const t7 of e5)
  814. this._refCounts.delete(t7);
  815. }
  816. async _processEditsRefetch(e5, t7, s4) {
  817. const i4 = (await t7(e5, s4)).features, { hasZ: r8, hasM: n6 } = this.featureStore;
  818. for (const l3 of i4) {
  819. const e6 = gt(this._tmpBoundingRect, l3.geometry, r8, n6);
  820. t(e6) || this._tileBounds.forEachInBounds(e6, (e7) => {
  821. const t8 = this._tiles.get(e7);
  822. this.featureStore.add(l3), t8.objectIds.has(l3.objectId) || (t8.objectIds.add(l3.objectId), this._referenceFeature(l3.objectId), this._tileFeatureCounts.set(t8.data.id, t8.objectIds.size));
  823. });
  824. }
  825. }
  826. process(e5, t7 = () => true) {
  827. if (t(this.tileInfo) || !e5.extent || r(this.extent) && !E(c2(this.extent, this._tmpBoundingRect), e5.extent))
  828. return new j5(e5);
  829. if (this._tiles.has(e5.id))
  830. return new j5(e5);
  831. const s4 = this._createTileTree(e5, this.tileInfo);
  832. return this._simplify(s4, t7, null, 0, 1), this._collectMissingTiles(e5, s4, this.tileInfo);
  833. }
  834. get debugInfo() {
  835. return Array.from(this._tiles.values()).map(({ data: e5 }) => ({ data: e5, featureCount: this._tileFeatureCounts.get(e5.id) || 0 }));
  836. }
  837. getFeatureCount(e5) {
  838. var _a;
  839. return (_a = this._tileFeatureCounts.get(e5.id)) != null ? _a : 0;
  840. }
  841. async fetchCount(e5, t7, s4, i4) {
  842. const r8 = this._tileFeatureCounts.get(e5.id);
  843. if (null != r8)
  844. return r8;
  845. const o4 = await S(t7, s4, i4);
  846. return this._tileFeatureCounts.set(e5.id, o4.data.count), o4.data.count;
  847. }
  848. _createTileTree(e5, t7) {
  849. const s4 = new I(e5.level, e5.row, e5.col);
  850. return t7.updateTileInfo(s4, j3.ExtrapolateOptions.POWER_OF_TWO), this._tileBounds.forEachInBounds(e5.extent, (i4) => {
  851. const r8 = this._tiles.get(i4).data;
  852. this._tilesAreRelated(e5, r8) && this._populateChildren(s4, r8, t7, this._tileFeatureCounts.get(r8.id) || 0);
  853. }), s4;
  854. }
  855. _tilesAreRelated(e5, t7) {
  856. if (!e5 || !t7)
  857. return false;
  858. if (e5.level === t7.level)
  859. return e5.row === t7.row && e5.col === t7.col;
  860. const s4 = e5.level < t7.level, i4 = s4 ? e5 : t7, r8 = s4 ? t7 : e5, o4 = 1 << r8.level - i4.level;
  861. return Math.floor(r8.row / o4) === i4.row && Math.floor(r8.col / o4) === i4.col;
  862. }
  863. _populateChildren(e5, t7, s4, i4) {
  864. const r8 = t7.level - e5.level - 1;
  865. if (r8 < 0)
  866. return void (e5.isLeaf = true);
  867. const o4 = t7.row >> r8, l3 = t7.col >> r8, a4 = e5.row << 1, c9 = l3 - (e5.col << 1) + (o4 - a4 << 1), h2 = e5.children[c9];
  868. if (r(h2))
  869. this._populateChildren(h2, t7, s4, i4);
  870. else {
  871. const r9 = new I(e5.level + 1, o4, l3);
  872. s4.updateTileInfo(r9, j3.ExtrapolateOptions.POWER_OF_TWO), e5.children[c9] = r9, this._populateChildren(r9, t7, s4, i4);
  873. }
  874. }
  875. _simplify(e5, t7, s4, i4, r8) {
  876. const o4 = r8 * r8;
  877. if (e5.isLeaf)
  878. return t7(this.getFeatureCount(e5), r8) ? 0 : (this._remove(e5), r(s4) && (s4.children[i4] = null), o4);
  879. const l3 = r8 / 2, a4 = l3 * l3;
  880. let c9 = 0;
  881. for (let h2 = 0; h2 < e5.children.length; h2++) {
  882. const s5 = e5.children[h2];
  883. c9 += r(s5) ? this._simplify(s5, t7, e5, h2, l3) : a4;
  884. }
  885. return 0 === c9 ? this._mergeChildren(e5) : 1 - c9 / o4 < w4 && (this._purge(e5), r(s4) && (s4.children[i4] = null), c9 = o4), c9;
  886. }
  887. _mergeChildren(e5) {
  888. const t7 = /* @__PURE__ */ new Set();
  889. let s4 = 0;
  890. this._forEachLeaf(e5, (e6) => {
  891. const i4 = this._tiles.get(e6.id);
  892. if (i4) {
  893. s4 += i4.byteSize;
  894. for (const e7 of i4.objectIds)
  895. t7.has(e7) || (t7.add(e7), this._referenceFeature(e7));
  896. this._remove(e6);
  897. }
  898. }), this._addTileStorage(e5, t7, s4), e5.isLeaf = true, e5.children[0] = e5.children[1] = e5.children[2] = e5.children[3] = null, this._tileFeatureCounts.set(e5.id, t7.size);
  899. }
  900. _forEachLeaf(e5, t7) {
  901. for (const s4 of e5.children)
  902. t(s4) || (s4.isLeaf ? t7(s4) : this._forEachLeaf(s4, t7));
  903. }
  904. _purge(e5) {
  905. if (!t(e5))
  906. if (e5.isLeaf)
  907. this._remove(e5);
  908. else
  909. for (let t7 = 0; t7 < e5.children.length; t7++) {
  910. const s4 = e5.children[t7];
  911. this._purge(s4), e5.children[t7] = null;
  912. }
  913. }
  914. _collectMissingTiles(e5, t7, s4) {
  915. const i4 = new F(s4, e5, this.extent);
  916. return this._collectMissingTilesRecurse(t7, i4, 1), i4.info;
  917. }
  918. _collectMissingTilesRecurse(e5, t7, s4) {
  919. if (e5.isLeaf)
  920. return;
  921. if (!e5.hasChildren)
  922. return void t7.addMissing(e5.level, e5.row, e5.col, s4);
  923. const i4 = s4 / 2;
  924. for (let r8 = 0; r8 < e5.children.length; r8++) {
  925. const s5 = e5.children[r8];
  926. t(s5) ? t7.addMissing(e5.level + 1, (e5.row << 1) + ((2 & r8) >> 1), (e5.col << 1) + (1 & r8), i4) : this._collectMissingTilesRecurse(s5, t7, i4);
  927. }
  928. }
  929. _referenceFeature(e5) {
  930. const t7 = (this._refCounts.get(e5) || 0) + 1;
  931. return this._refCounts.set(e5, t7), 1 === t7 ? x5.ADDED : x5.UNCHANGED;
  932. }
  933. _unreferenceFeature(e5) {
  934. const t7 = (this._refCounts.get(e5) || 0) - 1;
  935. return 0 === t7 ? (this._refCounts.delete(e5), x5.REMOVED) : (t7 > 0 && this._refCounts.set(e5, t7), x5.UNCHANGED);
  936. }
  937. get test() {
  938. return { tiles: Array.from(this._tiles.values()).map((e5) => `${e5.data.id}:[${Array.from(e5.objectIds)}]`), featureReferences: Array.from(this._refCounts.keys()).map((e5) => `${e5}:${this._refCounts.get(e5)}`) };
  939. }
  940. };
  941. function C2(e5) {
  942. return e5.reduce((e6, t7) => e6 + E3(t7), 0);
  943. }
  944. function E3(e5) {
  945. return 32 + S3(e5.geometry) + t4(e5.attributes);
  946. }
  947. function S3(e5) {
  948. if (t(e5))
  949. return 0;
  950. const t7 = c5(e5.lengths, 4);
  951. return 32 + c5(e5.coords, 8) + t7;
  952. }
  953. e([y2({ constructOnly: true })], v2.prototype, "featureStore", void 0), e([y2()], v2.prototype, "tileInfo", void 0), e([y2()], v2.prototype, "extent", void 0), e([y2()], v2.prototype, "maximumByteSize", void 0), v2 = e([n2("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTileStore")], v2);
  954. var T2 = class {
  955. constructor(e5, t7, s4) {
  956. this.data = e5, this.objectIds = t7, this.byteSize = s4;
  957. }
  958. };
  959. var I = class {
  960. constructor(e5, t7, s4) {
  961. this.level = e5, this.row = t7, this.col = s4, this.isLeaf = false, this.extent = null, this.children = [null, null, null, null];
  962. }
  963. get hasChildren() {
  964. return !this.isLeaf && (r(this.children[0]) || r(this.children[1]) || r(this.children[2]) || r(this.children[3]));
  965. }
  966. };
  967. var j5 = class {
  968. constructor(e5, t7 = []) {
  969. this.missingTiles = t7, this.fullArea = 0, this.coveredArea = 0, this.fullArea = y3(e5.extent), this.coveredArea = this.fullArea;
  970. }
  971. prepend(e5) {
  972. this.missingTiles = e5.missingTiles.concat(this.missingTiles), this.coveredArea += e5.coveredArea, this.fullArea += e5.fullArea;
  973. }
  974. };
  975. var F = class {
  976. constructor(e5, t7, s4) {
  977. this._tileInfo = e5, this._extent = null, this.info = new j5(t7), r(s4) && (this._extent = c2(s4));
  978. }
  979. addMissing(e5, t7, s4, i4) {
  980. const r8 = new t3(null, e5, t7, s4);
  981. this._tileInfo.updateTileInfo(r8, j3.ExtrapolateOptions.POWER_OF_TWO), t(r8.extent) || r(this._extent) && !E(this._extent, r8.extent) || (this.info.missingTiles.push({ data: r8, resolution: i4 }), this.info.coveredArea -= y3(r8.extent));
  982. }
  983. };
  984. var w4 = 0.18751;
  985. var x5;
  986. !function(e5) {
  987. e5[e5.ADDED = 0] = "ADDED", e5[e5.REMOVED = 1] = "REMOVED", e5[e5.UNCHANGED = 2] = "UNCHANGED";
  988. }(x5 || (x5 = {}));
  989. // node_modules/@arcgis/core/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js
  990. var E4 = class extends n3.EventedAccessor {
  991. constructor() {
  992. super(...arguments), this._isInitializing = true, this.remoteClient = null, this._whenSetup = A(), this._elevationAligner = r4(), this._elevationFilter = r5(), this._symbologyCandidatesFetcher = n5(), this._handles = new t2(), this._updatingHandles = new c3(), this._editsUpdatingHandles = new c3(), this._pendingApplyEdits = /* @__PURE__ */ new Map(), this._alignPointsInFeatures = async (e5, t7) => {
  993. const i4 = { points: e5 }, s4 = await this.remoteClient.invoke("alignElevation", i4, { signal: t7 });
  994. return f(t7), s4;
  995. }, this._getSymbologyCandidates = async (e5, t7) => {
  996. const i4 = { candidates: e5, spatialReference: this._spatialReference.toJSON() }, s4 = await this.remoteClient.invoke("getSymbologyCandidates", i4, { signal: t7 });
  997. return f(t7), s4;
  998. };
  999. }
  1000. get updating() {
  1001. return this.updatingExcludingEdits || this._editsUpdatingHandles.updating || this._featureFetcher.updating;
  1002. }
  1003. get updatingExcludingEdits() {
  1004. return this._featureFetcher.updatingExcludingEdits || this._isInitializing || this._updatingHandles.updating;
  1005. }
  1006. destroy() {
  1007. this._featureFetcher.destroy(), this._queryEngine.destroy(), this._featureStore.clear(), this._handles.destroy();
  1008. }
  1009. async setup(e5) {
  1010. const { geometryType: t7, objectIdField: i4, timeInfo: r8, fields: n6 } = e5.serviceInfo, { hasZ: o4 } = e5, p2 = k.fromJSON(e5.spatialReference);
  1011. this._spatialReference = p2, this._featureStore = new u2({ ...e5.serviceInfo, hasZ: o4, hasM: false }), this._queryEngine = new Y({ spatialReference: e5.spatialReference, featureStore: this._featureStore, geometryType: t7, fields: n6, hasZ: o4, hasM: false, objectIdField: i4, timeInfo: r8 ? v.fromJSON(r8) : null }), this._featureFetcher = new C({ store: new v2({ featureStore: this._featureStore }), url: e5.serviceInfo.url, objectIdField: e5.serviceInfo.objectIdField, globalIdField: e5.serviceInfo.globalIdField, capabilities: e5.serviceInfo.capabilities, spatialReference: p2, sourceSpatialReference: k.fromJSON(e5.serviceInfo.spatialReference) });
  1012. const d4 = "3d" === e5.configuration.viewType;
  1013. return this._elevationAligner = r4(d4, { elevationInfo: r(e5.elevationInfo) ? x3.fromJSON(e5.elevationInfo) : null, alignPointsInFeatures: this._alignPointsInFeatures, spatialReference: p2 }), this._elevationFilter = r5(d4), this._handles.add([l(() => this._featureFetcher.availability, (e6) => this.emit("notify-availability", { availability: e6 }), U), l(() => this.updating, () => this._notifyUpdating())]), this._whenSetup.resolve(), this._isInitializing = false, this.configure(e5.configuration);
  1014. }
  1015. async configure(e5) {
  1016. return await this._updatingHandles.addPromise(this._whenSetup.promise), this._updateFeatureFetcherConfiguration(e5), { result: {} };
  1017. }
  1018. async fetchCandidates(e5, t7) {
  1019. await this._whenSetup.promise, f(t7);
  1020. const i4 = j6(e5), r8 = r(t7) ? t7.signal : null, a4 = await this._queryEngine.executeQueryForSnapping(i4, r8);
  1021. f(r8);
  1022. const o4 = await this._elevationAligner.alignCandidates(a4.candidates, r8);
  1023. f(r8);
  1024. const l3 = await this._symbologyCandidatesFetcher.fetch(o4, r8);
  1025. f(r8);
  1026. const p2 = 0 === l3.length ? o4 : o4.concat(l3);
  1027. return { result: { candidates: this._elevationFilter.filter(i4, p2) } };
  1028. }
  1029. async updateTiles(e5, t7) {
  1030. return await this._updatingHandles.addPromise(this._whenSetup.promise), f(t7), this._featureFetcher.tileSize = e5.tileSize, this._featureFetcher.tilesOfInterest = e5.tiles, this._featureFetcher.tileInfo = r(e5.tileInfo) ? j3.fromJSON(e5.tileInfo) : null, C3;
  1031. }
  1032. async refresh(e5, t7) {
  1033. return await this._updatingHandles.addPromise(this._whenSetup.promise), f(t7), this._featureFetcher.refresh(), C3;
  1034. }
  1035. async whenNotUpdating(e5, t7) {
  1036. return await this._updatingHandles.addPromise(this._whenSetup.promise), f(t7), await j2(() => !this.updatingExcludingEdits, t7), f(t7), C3;
  1037. }
  1038. async getDebugInfo(e5, t7) {
  1039. return f(t7), { result: this._featureFetcher.debugInfo };
  1040. }
  1041. async beginApplyEdits(e5, t7) {
  1042. this._updatingHandles.addPromise(this._whenSetup.promise), f(t7);
  1043. const i4 = A();
  1044. return this._pendingApplyEdits.set(e5.id, i4), this._featureFetcher.applyEdits(i4.promise), this._editsUpdatingHandles.addPromise(i4.promise), C3;
  1045. }
  1046. async endApplyEdits(e5, t7) {
  1047. const i4 = this._pendingApplyEdits.get(e5.id);
  1048. return i4 && i4.resolve(e5.edits), f(t7), C3;
  1049. }
  1050. async notifyElevationSourceChange(e5, t7) {
  1051. return this._elevationAligner.notifyElevationSourceChange(), C3;
  1052. }
  1053. async notifySymbologyChange(e5, t7) {
  1054. return C3;
  1055. }
  1056. async setSymbologySnappingSupported(e5) {
  1057. return this._symbologyCandidatesFetcher = n5(e5, this._getSymbologyCandidates), C3;
  1058. }
  1059. _updateFeatureFetcherConfiguration(e5) {
  1060. this._featureFetcher.filter = r(e5.filter) ? x.fromJSON(e5.filter) : null, this._featureFetcher.customParameters = e5.customParameters;
  1061. }
  1062. _notifyUpdating() {
  1063. this.emit("notify-updating", { updating: this.updating });
  1064. }
  1065. };
  1066. e([y2({ readOnly: true })], E4.prototype, "updating", null), e([y2({ readOnly: true })], E4.prototype, "updatingExcludingEdits", null), e([y2()], E4.prototype, "_isInitializing", void 0), E4 = e([n2("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")], E4);
  1067. var b = E4;
  1068. function j6(e5) {
  1069. return { point: e5.point, distance: e5.distance, types: e5.types, query: r(e5.filter) ? e5.filter : { where: "1=1" } };
  1070. }
  1071. var C3 = { result: {} };
  1072. export {
  1073. b as default
  1074. };
  1075. //# sourceMappingURL=FeatureServiceSnappingSourceWorker-ID2DKINZ.js.map