import { R as R2, d as d5, r as r3 } from "./chunk-B2HJOMLZ.js"; import "./chunk-II7RCTF3.js"; import "./chunk-VS4BIQ2O.js"; import { n as n3, s as s6 } from "./chunk-HWIURR7X.js"; import "./chunk-Q4LKAPDF.js"; import "./chunk-TODU7HVH.js"; import "./chunk-23ONSYIH.js"; import { c as c4, l as l3, r as r2 } from "./chunk-U2FIWR5R.js"; import { A } from "./chunk-P2L4QEOI.js"; import { s as s7 } from "./chunk-D6FGJON6.js"; import "./chunk-YLVXZ2PS.js"; import { v as v2 } from "./chunk-T6STWTVU.js"; import "./chunk-546QCRS4.js"; import "./chunk-QXZVBSBH.js"; import "./chunk-YVTH4OGO.js"; import { o as o5 } from "./chunk-WFSV2B2I.js"; import "./chunk-4D6PVVFX.js"; import { Y } from "./chunk-NP2BYFXT.js"; import "./chunk-6H5PP7QI.js"; import "./chunk-HSPVIAVJ.js"; import "./chunk-XIEPNAEI.js"; import { f as f4, g as g3 } from "./chunk-M5BTTMP6.js"; import "./chunk-WQJRLXWG.js"; import "./chunk-ETWBEEKL.js"; import "./chunk-XZA4MVET.js"; import "./chunk-J525NRN3.js"; import "./chunk-MI7HWWFL.js"; import "./chunk-D5GG5NVO.js"; import "./chunk-USORKAIZ.js"; import { s as s5 } from "./chunk-Q34L5KZA.js"; import { l as l4 } from "./chunk-TYZ4SNOQ.js"; import { l as l2 } from "./chunk-LMCIAW5S.js"; import { h } from "./chunk-OTS3UE5B.js"; import "./chunk-6RAL4JPQ.js"; import { i } from "./chunk-VAY3LZG7.js"; import "./chunk-LGW7TID4.js"; import { c as c5 } from "./chunk-6SASJ6IM.js"; import "./chunk-3OHML7FO.js"; import { c as c3, f as f5 } from "./chunk-GS2NUWMB.js"; import "./chunk-FUEX356Y.js"; import { c as c2, q } from "./chunk-54AOZV5X.js"; import { a as a2 } from "./chunk-PK35UGFJ.js"; import "./chunk-H6ETEALK.js"; import "./chunk-FIYKFRB2.js"; import "./chunk-ROWZMUVJ.js"; import "./chunk-7IKYLNB5.js"; import "./chunk-P4UZNLD5.js"; import { D as D2, M as M2, Q, b as b2, ce, ie, me, ne, ue } from "./chunk-FYNVVMWY.js"; import "./chunk-Q52DVFYK.js"; import { o as o2, s as s4, t as t3 } from "./chunk-HBMVUVZX.js"; import "./chunk-QOV6ITMI.js"; import "./chunk-DH2OBAUC.js"; import { o as o4 } from "./chunk-TNLRDNTC.js"; import { b as b3 } from "./chunk-UD63WBG3.js"; import { g as g4 } from "./chunk-X7DBH4KK.js"; import { a as a3, m as m2, y as y2 } from "./chunk-LY74KTXV.js"; import "./chunk-EWE6EXPY.js"; import "./chunk-KUXNUNAI.js"; import { d as d3 } from "./chunk-KMAHKQ2G.js"; import "./chunk-522WBHUO.js"; import "./chunk-WNCU6BFU.js"; import "./chunk-BJHM4JNS.js"; import "./chunk-F6A2QQ26.js"; import "./chunk-EOSZHC5H.js"; import "./chunk-C43UE3Z5.js"; import { d as d4 } from "./chunk-RMX2AZ4P.js"; import "./chunk-NE3ESGA6.js"; import { f as f3, j as j2, l } from "./chunk-YIS6BAC3.js"; import "./chunk-7XXXCK2A.js"; import "./chunk-7ZIDBK7B.js"; import { y } from "./chunk-EG5OI4V4.js"; import "./chunk-65BYCSII.js"; import "./chunk-WZQZRKNH.js"; import "./chunk-LRDX4TO7.js"; import { S } from "./chunk-RBZL6SRZ.js"; import "./chunk-WDLTDV2L.js"; import "./chunk-TERAW6FT.js"; import "./chunk-N2663GRX.js"; import "./chunk-O4FY3ITT.js"; import "./chunk-WEMIK25H.js"; import "./chunk-JXW4QTJA.js"; import "./chunk-UXF37FQ4.js"; import "./chunk-ZOEK6QHJ.js"; import { o2 as o3 } from "./chunk-XNLG7T2T.js"; import "./chunk-IR4PV7VK.js"; import { d as d2 } from "./chunk-2Z6LERTI.js"; import { v2 as v } from "./chunk-OWVBLVP3.js"; import "./chunk-MXB2XLKV.js"; import "./chunk-ALDCDSPV.js"; import { n as n2 } from "./chunk-DT6EAZQ5.js"; import "./chunk-HNOZUNJ4.js"; import { U } from "./chunk-VNFRAYHO.js"; import "./chunk-R5IG2D6H.js"; import { Bt } from "./chunk-VBRY5KJM.js"; import "./chunk-PDKDCAAD.js"; import { M2 as M, s as s3 } from "./chunk-ECW2QABR.js"; import "./chunk-GCDJLKH4.js"; import { E as E3, R, k2 as k } from "./chunk-MRJEICT6.js"; import { d, e, n2 as n } from "./chunk-Y3WMVFTW.js"; import "./chunk-SAS7RONY.js"; import "./chunk-WSRBH7BF.js"; import "./chunk-IHXECKQQ.js"; import { C, D, E as E2, L, b, f as f2, g as g2, j } from "./chunk-ULGDPLM2.js"; import { s, s3 as s2 } from "./chunk-EMJ4ZSM2.js"; import "./chunk-IKP3YN53.js"; import { E, a, c, e as e2, f, g, m, o, r, t, t2 } from "./chunk-GZT4BVFP.js"; import "./chunk-A5ICIBVI.js"; // node_modules/@arcgis/core/views/2d/layers/features/processors.js function o6(o11) { return o11 === "heatmap" ? import("./HeatmapProcessor-ZTNOMUTP.js") : import("./SymbolProcessor-QOW6BODF.js"); } // node_modules/@arcgis/core/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js var r4 = 268435455; var n4 = class { constructor() { this.fieldMap = new Map(), this.fields = [], this.hasFeatures = false, this.fieldCount = 0, this.featureCount = 0, this.objectIdFieldIndex = 0, this.vertexCount = 0, this.offsets = { attributes: new Array(), geometry: new Array() }, this.centroid = new Array(); } hasField(e3) { return this.fieldMap.has(e3); } isDateField(e3) { return this.fieldMap.get(e3)?.isDate; } getFieldIndex(e3) { return this.fieldMap.get(e3)?.index; } }; function a4(e3) { const t7 = 1, r5 = 2, n6 = e3.getLength(), a8 = e3.pos() + n6, i4 = { name: "", isDate: false }; for (; e3.pos() < a8 && e3.next(); ) switch (e3.tag()) { case t7: i4.name = e3.getString(); break; case r5: c2(e3.getEnum()) === "esriFieldTypeDate" && (i4.isDate = true); break; default: e3.skip(); } return i4; } function i2(e3) { return e3.toLowerCase().trim(); } function o7(s8, o11, c12 = false) { const f10 = 1, d11 = 3, u5 = 9, l9 = 12, g9 = 13, p5 = 15, h6 = s8.pos(), m7 = new n4(); let b5 = 0, w5 = 0; const k3 = 1, x5 = 2, y8 = 4, I2 = 3; let F4 = null, L4 = null, A4 = null, C2 = false; for (; s8.next(); ) switch (s8.tag()) { case f10: F4 = s8.getString(); break; case d11: L4 = s8.getString(); break; case l9: A4 = s8.processMessage(q); break; case u5: if (m7.exceededTransferLimit = s8.getBool(), m7.exceededTransferLimit) { m7.offsets.geometry = c12 ? new Float64Array(8e3) : new Int32Array(8e3), m7.centroid = c12 ? new Float64Array(16e3) : new Int32Array(16e3); for (let e3 = 0; e3 < m7.centroid.length; e3++) m7.centroid[e3] = r4; } break; case g9: { const e3 = a4(s8), t7 = e3.name, r5 = i2(e3.name), n6 = { fieldName: t7, index: b5++, isDate: e3.isDate }; m7.fields.push(n6), m7.fieldMap.set(e3.name, n6), m7.fieldMap.set(r5, n6); break; } case p5: { const e3 = s8.getLength(), t7 = s8.pos() + e3; if (!m7.exceededTransferLimit) { const e4 = m7.offsets.geometry, t8 = m7.centroid; e4.push(0), t8.push(r4), t8.push(r4); } !C2 && m7.exceededTransferLimit && (C2 = true, m7.offsets.attributes = c12 ? new Float64Array(8e3 * b5) : new Uint32Array(8e3 * b5)); let n6 = w5 * b5; for (; s8.pos() < t7 && s8.next(); ) switch (s8.tag()) { case k3: { if (C2) m7.offsets.attributes[n6++] = s8.pos(); else { m7.offsets.attributes.push(s8.pos()); } const e4 = s8.getLength(); s8.skipLen(e4); break; } case x5: if (o11) { const e4 = s8.getLength(), t8 = s8.pos() + e4; for (; s8.pos() < t8 && s8.next(); ) switch (s8.tag()) { case I2: { s8.getUInt32(); const e5 = s8.getSInt64(), t9 = s8.getSInt64(); m7.centroid[2 * w5] = e5, m7.centroid[2 * w5 + 1] = t9; break; } default: s8.skip(); } } else { m7.offsets.geometry[w5] = s8.pos(); const e4 = s8.getLength(); m7.vertexCount += e4, s8.skipLen(e4); } break; case y8: { const e4 = s8.getLength(), t8 = s8.pos() + e4; for (; s8.pos() < t8 && s8.next(); ) switch (s8.tag()) { case I2: { s8.getUInt32(); const e5 = s8.getSInt64(), t9 = s8.getSInt64(); m7.centroid[2 * w5] = e5, m7.centroid[2 * w5 + 1] = t9; break; } default: s8.skip(); } break; } default: s8.skip(); } w5++, m7.hasFeatures = true; break; } default: s8.skip(); } const S4 = F4 || L4; if (!S4) throw new s2("FeatureSet has no objectId or globalId field name"); return m7.featureCount = w5, m7.fieldCount = b5, m7.objectIdFieldIndex = m7.getFieldIndex(S4), m7.transform = A4, m7.displayIds = new Uint32Array(m7.featureCount), m7.groupIds = new Uint16Array(m7.featureCount), s8.move(h6), m7; } // node_modules/@arcgis/core/views/2d/layers/features/support/FeatureSetReaderPBF.js var c6 = s.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF"); var g5 = true; var l5 = 268435455; var _ = 128; var f6 = 128e3; var y3 = { small: { delta: new Int32Array(_), decoded: new Int32Array(_) }, large: { delta: new Int32Array(f6), decoded: new Int32Array(f6) } }; function I(e3) { return e3 <= y3.small.delta.length ? y3.small : (e3 <= y3.large.delta.length || (y3.large.delta = new Int32Array(Math.round(1.25 * e3)), y3.large.decoded = new Int32Array(Math.round(1.25 * e3))), y3.large); } function p(e3) { return e3.toLowerCase().trim(); } function m3(t7) { try { const e3 = 2, r5 = new a2(new Uint8Array(t7), new DataView(t7)); for (; r5.next(); ) { if (r5.tag() === e3) return x(r5.getMessage()); r5.skip(); } } catch (r5) { const t8 = new s2("query:parsing-pbf", "Error while parsing FeatureSet PBF payload", { error: r5 }); c6.error(t8); } return null; } function x(e3) { const t7 = 1; for (; e3.next(); ) { if (e3.tag() === t7) return e3.getMessage(); e3.skip(); } return null; } function S2(e3) { const t7 = 1, r5 = 2, s8 = 3, i4 = 4, n6 = 5, a8 = 6, h6 = 7, o11 = 8, d11 = 9, u5 = e3.getLength(), c12 = e3.pos() + u5; for (; e3.pos() < c12 && e3.next(); ) switch (e3.tag()) { case t7: return e3.getString(); case r5: return e3.getFloat(); case s8: return e3.getDouble(); case i4: return e3.getSInt32(); case n6: return e3.getUInt32(); case a8: return e3.getInt64(); case h6: return e3.getUInt64(); case o11: return e3.getSInt64(); case d11: return e3.getBool(); default: return e3.skip(), null; } return null; } function F(e3, t7, r5, s8, i4, n6) { return 0.5 * Math.abs(e3 * s8 + r5 * n6 + i4 * t7 - e3 * n6 - r5 * t7 - i4 * s8); } function G(e3, t7, r5, s8) { return e3 * s8 - r5 * t7 === 0 && e3 * r5 + t7 * s8 > 0; } var w = class extends A { constructor(e3, t7, r5, s8) { super(e3, s8), this._hasNext = false, this._isPoints = false, this._featureIndex = -1, this._featureOffset = 0, this._cache = { area: 0, unquantGeometry: void 0, geometry: void 0, centroid: void 0, legacyFeature: void 0, optFeature: void 0 }, this._geometryType = s8.geometryType, this._reader = t7, this._header = r5, this._hasNext = r5.hasFeatures, this._isPoints = s8.geometryType === "esriGeometryPoint"; } static fromBuffer(e3, t7, r5 = false) { const s8 = t7.geometryType, i4 = m3(e3), n6 = o7(i4, s8 === "esriGeometryPoint", r5), a8 = A.createInstance(); return new w(a8, i4, n6, t7); } get geometryType() { return this._geometryType; } get size() { return this._header.featureCount; } get hasZ() { return false; } get hasM() { return false; } get stride() { return 2 + (this.hasZ ? 1 : 0) + (this.hasM ? 1 : 0); } get hasFeatures() { return this._header.hasFeatures; } get hasNext() { return this._hasNext; } get exceededTransferLimit() { return this._header.exceededTransferLimit; } hasField(e3) { return this._header.hasField(e3) || this._header.hasField(p(e3)); } getFieldNames() { return this._header.fields.map((e3) => e3.fieldName); } getSize() { return this.size; } getQuantizationTransform() { return this._header.transform; } getCursor() { return this.copy(); } getIndex() { return this._featureIndex; } setIndex(e3) { this._cache.area = 0, this._cache.unquantGeometry = void 0, this._cache.geometry = void 0, this._cache.centroid = void 0, this._cache.legacyFeature = void 0, this._cache.optFeature = void 0, this._featureIndex = e3; } getAttributeHash() { let e3 = ""; return this._header.fields.forEach(({ index: t7 }) => { e3 += this._readAttributeAtIndex(t7) + "."; }), e3; } getObjectId() { return this._readAttributeAtIndex(this._header.objectIdFieldIndex); } getDisplayId() { return this._header.displayIds[this._featureIndex]; } setDisplayId(e3) { this._header.displayIds[this._featureIndex] = e3; } getGroupId() { return this._header.groupIds[this._featureIndex]; } setGroupId(e3) { this._header.groupIds[this._featureIndex] = e3; } readLegacyFeature() { if (this._cache.legacyFeature === void 0) { const e3 = this.readCentroid(), t7 = { attributes: this.readAttributes(), geometry: this._isPoints ? this.readLegacyPointGeometry() : this.readLegacyGeometry(), centroid: (e3 && { x: e3.coords[0], y: e3.coords[1] }) ?? null }; return this._cache.legacyFeature = t7, t7; } return this._cache.legacyFeature; } readOptimizedFeature() { if (this._cache.optFeature === void 0) { const e3 = new s4(this.readGeometry(), this.readAttributes(), this.readCentroid()); return e3.objectId = this.getObjectId(), e3.displayId = this.getDisplayId(), this._cache.optFeature = e3, e3; } return this._cache.optFeature; } getXHydrated() { const e3 = this._header.centroid[2 * this._featureIndex], t7 = this.getQuantizationTransform(); return t(t7) ? e3 : e3 * t7.scale[0] + t7.translate[0]; } getYHydrated() { const e3 = this._header.centroid[2 * this._featureIndex + 1], t7 = this.getQuantizationTransform(); return t(t7) ? e3 : t7.translate[1] - e3 * t7.scale[1]; } getX() { return this._header.centroid[2 * this._featureIndex] * this._sx + this._tx; } getY() { return this._header.centroid[2 * this._featureIndex + 1] * this._sy + this._ty; } readLegacyPointGeometry() { return { x: this.getX(), y: this.getY() }; } readLegacyGeometry(e3) { const t7 = this.readGeometry(e3); return ne(t7, this.geometryType, false, false); } readLegacyCentroid() { const e3 = this.readCentroid(); if (!e3) return null; const [t7, r5] = e3.coords; return { x: t7, y: r5 }; } readGeometryArea() { return this._cache.area || this.readGeometry(true), this._cache.area; } readUnquantizedGeometry(e3 = false) { if (this._cache.unquantGeometry === void 0) { const t7 = this.readGeometry(e3); if (!t7) return this._cache.unquantGeometry = null, null; const r5 = I(t7.coords.length).decoded, s8 = t7.clone(r5), i4 = s8.coords; let n6 = 0; for (const e4 of s8.lengths) { for (let t8 = 1; t8 < e4; t8++) { const e5 = 2 * (n6 + t8), r6 = 2 * (n6 + t8 - 1); i4[e5] += i4[r6], i4[e5 + 1] += i4[r6 + 1]; } n6 += e4; } return this._cache.unquantGeometry = s8, s8; } return this._cache.unquantGeometry; } readHydratedGeometry() { if (this._isPoints) { if (this._header.centroid[2 * this._featureIndex] === l5) return null; const e4 = this.getXHydrated(), t8 = this.getYHydrated(); return new t3([], [e4, t8]); } const e3 = this.readGeometry(); if (!e3) return null; const t7 = e3.clone(), r5 = this.getQuantizationTransform(); return r(r5) && me(t7, t7, this.hasZ, this.hasM, r5), t7; } readGeometry(e3 = false) { if (this._cache.geometry === void 0) { let r5 = null; if (this._isPoints) { if (this._header.centroid[2 * this._featureIndex] === l5) return null; const e4 = this.getX(), t7 = this.getY(); r5 = new t3([], [e4, t7]); } else { const s8 = this._header.offsets.geometry[this._featureIndex], i4 = this._reader; if (s8 === 0) return null; i4.move(s8); try { r5 = e3 ? this._parseGeometryForDisplay(i4) : this._parseGeometry(i4); } catch (t7) { return console.error("Failed to parse geometry!", t7), null; } } return this._cache.geometry = r5, r5; } return this._cache.geometry; } readCentroid() { if (this._cache.centroid === void 0) { let e3 = null; const t7 = this._header.centroid[2 * this._featureIndex] + this._tx, r5 = this._header.centroid[2 * this._featureIndex + 1] + this._ty; return t7 === l5 ? (e3 = this._computeCentroid(), e3 && (this._header.centroid[2 * this._featureIndex] = e3.coords[0] - this._tx, this._header.centroid[2 * this._featureIndex + 1] = e3.coords[1] - this._ty)) : e3 = new t3([], [t7, r5]), this._cache.centroid = e3, e3; } return this._cache.centroid; } copy() { const e3 = this._reader.clone(), t7 = new w(this.instance, e3, this._header, this.fullSchema()); return this.copyInto(t7), t7; } next() { for (this._cache.area = 0, this._cache.unquantGeometry = void 0, this._cache.geometry = void 0, this._cache.centroid = void 0, this._cache.legacyFeature = void 0, this._cache.optFeature = void 0; ++this._featureIndex < this.size && !this._getExists(); ) ; return this._featureIndex < this.size; } _readAttribute(e3, t7) { const r5 = this._header.hasField(e3) ? e3 : p(e3), s8 = this._header.getFieldIndex(r5); if (s8 == null) return; const i4 = this._readAttributeAtIndex(s8); if (!t7) return i4; if (i4 == null) return i4; return this._header.isDateField(r5) ? new Date(i4) : i4; } _readAttributes() { const e3 = {}; return this._header.fields.forEach(({ fieldName: t7, index: r5 }) => { e3[t7] = this._readAttributeAtIndex(r5); }), e3; } copyInto(e3) { super.copyInto(e3), e3._featureIndex = this._featureIndex, e3._featureOffset = this._featureOffset, e3._hasNext = this._hasNext; } _readAttributeAtIndex(e3) { const t7 = this._header.offsets.attributes[this._featureIndex * this._header.fieldCount + e3], r5 = this._reader; return r5.move(t7), S2(r5); } _parseGeometry(e3) { const t7 = 2, r5 = 3, s8 = e3.getLength(), i4 = e3.pos() + s8, n6 = [], a8 = []; for (; e3.pos() < i4 && e3.next(); ) switch (e3.tag()) { case t7: { const t8 = e3.getUInt32(), r6 = e3.pos() + t8; for (; e3.pos() < r6; ) a8.push(e3.getUInt32()); break; } case r5: { const t8 = e3.getUInt32(), r6 = e3.pos() + t8; for (n6.push(e3.getSInt32() + this._tx), n6.push(e3.getSInt32() + this._ty), this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(); e3.pos() < r6; ) n6.push(e3.getSInt32()), n6.push(e3.getSInt32()), this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(); break; } default: e3.skip(); } return new t3(a8, n6); } _parseGeometryForDisplay(e3) { const t7 = 2, r5 = 3, s8 = e3.getLength(), i4 = e3.pos() + s8, n6 = [], a8 = []; let h6 = 0, d11 = 0, u5 = null, c12 = 0; const l9 = this.geometryType === "esriGeometryPolygon"; for (; e3.pos() < i4 && e3.next(); ) switch (e3.tag()) { case t7: { const t8 = e3.getUInt32(), r6 = e3.pos() + t8; for (; e3.pos() < r6; ) { const t9 = e3.getUInt32(); n6.push(t9), h6 += t9; } u5 = I(2 * h6).delta; break; } case r5: { e3.getUInt32(); const t8 = 2 + (this.hasZ ? 1 : 0) + (this.hasM ? 1 : 0); for (const r6 of n6) if (d11 + t8 * r6 > u5.length) for (let t9 = 0; t9 < r6; t9++) e3.getSInt32(), e3.getSInt32(), this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(); else if (l9 && g5) { const t9 = this.getAreaSimplificationThreshold(r6, this._header.vertexCount); let s9 = 2, i5 = 1; const n7 = false; let h7 = e3.getSInt32(), o11 = e3.getSInt32(); u5[d11++] = h7, u5[d11++] = o11, this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(); let g9 = e3.getSInt32(), l10 = e3.getSInt32(); for (this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(); s9 < r6; ) { let r7 = e3.getSInt32(), n8 = e3.getSInt32(); this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(); const a9 = h7 + g9, _4 = o11 + l10; F(h7, o11, a9, _4, a9 + r7, _4 + n8) >= t9 ? (c12 += -0.5 * (a9 - h7) * (_4 + o11), i5 > 1 && G(u5[d11 - 2], u5[d11 - 1], g9, l10) ? (u5[d11 - 2] += g9, u5[d11 - 1] += l10) : (u5[d11++] = g9, u5[d11++] = l10, i5++), h7 = a9, o11 = _4) : (r7 += g9, n8 += l10), g9 = r7, l10 = n8, s9++; } i5 < 3 || n7 ? d11 -= 2 * i5 : (c12 += -0.5 * (h7 + g9 - h7) * (o11 + l10 + o11), G(u5[d11 - 2], u5[d11 - 1], g9, l10) ? (u5[d11 - 2] += g9, u5[d11 - 1] += l10, a8.push(i5)) : (u5[d11++] = g9, u5[d11++] = l10, a8.push(++i5))); } else { let t9 = 0, s9 = e3.getSInt32(), i5 = e3.getSInt32(); this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(), u5[d11++] = s9, u5[d11++] = i5, t9 += 1; for (let n7 = 1; n7 < r6; n7++) { const r7 = e3.getSInt32(), a9 = e3.getSInt32(), h7 = s9 + r7, o11 = i5 + a9; c12 += -0.5 * (h7 - s9) * (o11 + i5), this.hasZ && e3.getSInt32(), this.hasM && e3.getSInt32(), n7 > 2 && G(u5[d11 - 2], u5[d11 - 1], r7, a9) ? (u5[d11 - 2] += r7, u5[d11 - 1] += a9) : (u5[d11++] = r7, u5[d11++] = a9, t9 += 1), s9 = h7, i5 = o11; } a8.push(t9); } break; } default: e3.skip(); } if (this._cache.area = c12, !a8.length) return null; if (this._tx || this._ty) { let e4 = 0; for (const t8 of a8) u5[2 * e4] += this._tx, u5[2 * e4 + 1] += this._ty, e4 += t8; } return new t3(a8, u5); } }; // node_modules/@arcgis/core/views/2d/layers/features/controllers/support/sourceAdapters.js var l6 = class { constructor(e3) { this.service = e3; } destroy() { } }; function f7(e3) { return Array.isArray(e3.source); } function y4(e3) { return e3 && e3.capabilities && e3.collection && e3.layerDefinition; } function h2(t7) { const { capabilities: r5 } = t7; return y4(t7.source) ? new w2(t7) : f7(t7) ? new v3(t7) : r5.query.supportsFormatPBF && a("featurelayer-pbf") ? new F2(t7) : new q2(t7); } async function d6(e3) { const t7 = new c5(); return await t7.open(e3, {}), t7; } var v3 = class extends l6 { constructor(e3) { super(e3), this._portsOpen = d6(e3.source).then((e4) => this.client = e4); } destroy() { this.client.close(), this.client = null; } async executeQuery(e3, t7) { await this._portsOpen; const r5 = await this.client.invoke("queryFeatures", e3.toJSON(), t7); return d5.fromFeatureSet(r5, this.service); } }; var F2 = class extends l6 { async executeQuery(e3, t7) { const { data: r5 } = await f5(this.service.source, e3, t7), s8 = !e3.quantizationParameters; return w.fromBuffer(r5, this.service, s8); } }; var q2 = class extends l6 { async executeQuery(e3, s8) { const { source: n6, capabilities: c12, spatialReference: p5, objectIdField: l9, geometryType: f10 } = this.service; if (r(e3.quantizationParameters) && !c12.query.supportsQuantization) { const t7 = e3.clone(), c13 = s5(e2(t7.quantizationParameters)); t7.quantizationParameters = null; const { data: f11 } = await c3(n6, t7, p5, s8), y9 = ce(f11, l9); return ue(c13, y9), d5.fromOptimizedFeatureSet(y9, this.service); } const { data: y8 } = await c3(n6, e3, this.service.spatialReference, s8); return f10 === "esriGeometryPoint" && (y8.features = y8.features?.filter((e4) => { if (r(e4.geometry)) { const t7 = e4.geometry; return Number.isFinite(t7.x) && Number.isFinite(t7.y); } return true; })), d5.fromFeatureSet(y8, this.service); } }; var w2 = class extends l6 { async executeQuery(e3, t7) { const { capabilities: s8 } = this.service; if (e3.quantizationParameters && !s8.query.supportsQuantization) { const s9 = e3.clone(), a9 = s5(e2(s9.quantizationParameters)); s9.quantizationParameters = null; const c12 = await v2(this.service.source, e3, t7); return ue(a9, c12), d5.fromOptimizedFeatureSet(c12, this.service); } const a8 = await v2(this.service.source, e3, t7); return d5.fromOptimizedFeatureSet(a8, this.service); } }; // node_modules/@arcgis/core/views/2d/layers/features/support/UpdateToken.js var t4 = class { constructor() { this.version = 0, this.source = false, this.targets = { feature: false, aggregate: false }, this.storage = { filters: false, data: false }, this.mesh = false, this.queryFilter = false, this.why = { mesh: [], source: [] }; } static create(e3) { const s8 = new t4(); for (const t7 in e3) { const r5 = e3[t7]; if (typeof r5 == "object") for (const e4 in r5) { const a8 = r5[e4]; s8[t7][e4] = a8; } s8[t7] = r5; } return s8; } static empty() { return t4.create({}); } static all() { return t4.create({ source: true, targets: { feature: true, aggregate: true }, storage: { filters: true, data: true }, mesh: true }); } unset(t7) { this.version = t7.version, t7.source && (this.source = false), t7.targets.feature && (this.targets.feature = false), t7.targets.aggregate && (this.targets.aggregate = false), t7.storage.filters && (this.storage.filters = false), t7.storage.data && (this.storage.data = false), t7.mesh && (this.mesh = false), t7.queryFilter && (this.queryFilter = false); } any() { return this.source || this.mesh || this.storage.filters || this.storage.data || this.targets.feature || this.targets.aggregate || this.queryFilter; } describe() { let t7 = 0, e3 = ""; if (this.mesh) { t7 += 20, e3 += "-> (20) Mesh needs update\n"; for (const t8 of this.why.mesh) e3 += ` + ${t8} `; } if (this.source) { t7 += 10, e3 += "-> (10) The source needs update\n"; for (const t8 of this.why.source) e3 += ` + ${t8} `; } this.targets.feature && (t7 += 5, e3 += "-> (5) Feature target parameters changed\n"), this.storage.filters && (t7 += 5, e3 += "-> (5) Feature filter parameters changed\n"), this.targets.aggregate && (t7 += 4, e3 += "-> (4) Aggregate target parameters changed\n"), this.storage.data && (t7 += 1, e3 += "-> (1) Texture storage parameters changed"); const s8 = t7 < 5 ? "Fastest" : t7 < 10 ? "Fast" : t7 < 15 ? "Moderate" : t7 < 20 ? "Slow" : "Very Slow"; console.debug(`Applying ${s8} update of cost ${t7}/45 `), console.debug(e3); } toJSON() { return { queryFilter: this.queryFilter, source: this.source, targets: this.targets, storage: this.storage, mesh: this.mesh }; } }; // node_modules/@arcgis/core/views/2d/layers/features/sources/DataTileSubscription.js var o8 = class { constructor(s8, t7) { this.requests = { done: new Array(), stream: new s7(10) }, this._edits = null, this._abortController = new AbortController(), this._version = 0, this._done = false, this.didSend = false, this.tile = s8, this._version = t7; } get signal() { return this._abortController.signal; } get options() { return { signal: this._abortController.signal }; } get empty() { return !this.requests.done.length; } get edits() { return this._edits; } get done() { return this._done; } end() { this._done = true; } clear() { this.requests.done = []; } applyUpdate(e3) { this.requests.done.forEach((s8) => s8.message.status.unset(e3)), this._version = e3.version, r(this._edits) && this._edits.status.unset(e3); } add(e3) { e3.message.status = e3.message.status ?? t4.empty(), e3.message.status.version = this._version, a("esri-2d-update-debug") && console.debug(this.tile.id, "DataTileSubscription:add", this._version), e3.message.end && this.requests.done.forEach((e4) => { r(e4.message) && e4.message.end && (e4.message.end = false); }), this.requests.done.push(e3); } edit(e3, s8) { const t7 = e3.getQuantizationTransform(), o11 = e3.fullSchema(), n6 = Array.from(e3.features()), h6 = [...s8, ...n6.map((e4) => e4.objectId)]; if (this.removeIds(h6), this._invalidate(), t(this._edits)) return void (this._edits = { type: "append", addOrUpdate: d5.fromOptimizedFeatures(n6, o11, e2(t7)), id: this.tile.id, status: t4.empty(), end: true }); this.requests.done.forEach((e4) => e4.message.end = false); e2(this._edits.addOrUpdate).append(e3.features()); } *readers() { for (const { message: e3 } of this.requests.done) r(e3.addOrUpdate) && (yield e3.addOrUpdate); r(this._edits) && r(this._edits.addOrUpdate) && (yield this._edits.addOrUpdate); } _invalidate() { for (const e3 of this.requests.done) e3.message.status = t4.empty(); r(this._edits) && (this._edits.status = t4.empty()); } removeIds(e3) { this._invalidate(); for (const { message: s8 } of this.requests.done) { const r5 = s8.addOrUpdate; r(r5) && (r5.removeIds(e3), r5.isEmpty && (s8.addOrUpdate = null)); } r(this._edits) && r(this._edits.addOrUpdate) && this._edits.addOrUpdate.removeIds(e3), this.requests.done = this.requests.done.filter((e4) => e4.message.addOrUpdate || e4.message.end); } abort() { this._abortController.abort(); } }; // node_modules/@arcgis/core/views/2d/layers/features/sources/DataTileSource.js function m4(e3, s8) { const t7 = new Set(); return e3 && e3.forEach((e4) => t7.add(e4)), s8 && s8.forEach((e4) => t7.add(e4)), t7.has("*") ? ["*"] : Array.from(t7); } var f8 = class { constructor(e3) { this.events = new n2(), this._resolver = D(), this._didEdit = false, this._subscriptions = new Map(), this._outSR = e3.outSR, this._serviceInfo = e3.serviceInfo, this._onTileUpdateMessage = e3.onMessage; } destroy() { } async _onMessage(e3) { const s8 = this._subscriptions.get(e3.id); if (!s8) return; const t7 = { ...e3, remove: e3.remove ?? [], status: e3.status ?? t4.empty() }; return j(this._onTileUpdateMessage(t7, s8.options)); } update(s8, r5) { const i4 = r5.fields.length; r5.outFields = m4(this._schema?.outFields, r5.outFields), r5.outFields = r5.outFields.length >= 0.75 * i4 ? ["*"] : r5.outFields, r5.outFields.sort(); const o11 = m2(this._schema, r5); if (!o11) return; a("esri-2d-update-debug") && console.debug("Applying Update - Source:", o11); const n6 = "orderByFields" in this._serviceInfo && this._serviceInfo.orderByFields ? this._serviceInfo.orderByFields : this._serviceInfo.objectIdField + " ASC", c12 = { returnCentroid: a("esri-2d-query-centroid-enabled") && this._serviceInfo.geometryType === "esriGeometryPolygon", returnGeometry: true, timeReferenceUnknownClient: this._serviceInfo.type !== "stream" && this._serviceInfo.timeReferenceUnknownClient, outFields: r5.outFields, outSpatialReference: this._outSR, orderByFields: [n6], where: r5.definitionExpression || "1=1", gdbVersion: r5.gdbVersion, historicMoment: r5.historicMoment, timeExtent: y.fromJSON(r5.timeExtent) }, d11 = this._schema && a3(o11, "outFields"); this._schema && y2(o11, ["timeExtent", "definitionExpression", "gdbVersion", "historicMoment", "customParameters"]) && (s8.why.mesh.push("Layer filter and/or custom parameters changed"), s8.why.source.push("Layer filter and/or custom parameters changed"), s8.mesh = true, s8.source = true, s8.queryFilter = true), d11 && (s8.why.source.push("Layer required fields changed"), s8.source = true), m2(c12, this._queryInfo) && (this._queryInfo = c12), this._schema = r5, this._resolver.resolve(); } whenInitialized() { return this._resolver.promise; } async applyUpdate(e3) { if (e3.queryFilter || e3.source && this._didEdit) return this.refresh(e3.version), void (this._didEdit = false); this._subscriptions.forEach((s8) => s8.applyUpdate(e3)), await this.resend(); } refresh(e3) { for (const s8 of this._tiles()) this.unsubscribe(s8), this.subscribe(s8, e3); } subscribe(e3, s8) { const t7 = new o8(e3, s8); this._subscriptions.set(e3.id, t7); } unsubscribe(e3) { const s8 = this.get(e3.id); r(s8) && s8.abort(), this._subscriptions.delete(e3.id); } createQuery(e3 = {}) { const s8 = this._queryInfo.historicMoment ? new Date(this._queryInfo.historicMoment) : null; return new b3({ ...this._queryInfo, historicMoment: s8, ...e3 }); } get(e3) { return this._subscriptions.has(e3) ? this._subscriptions.get(e3) : null; } async queryLastEditDate() { throw new Error("Service does not support query type"); } async query(e3) { throw new Error("Service does not support query"); } *_tiles() { const e3 = Array.from(this._subscriptions.values()); for (const s8 of e3) yield s8.tile; } async edit(e3, s8) { const t7 = Array.from(this._subscriptions.values()), r5 = t7.map(({ tile: e4 }) => e4); for (const i4 of t7) i4.removeIds(s8); if (e3.length) { const t8 = r5.map((s9) => { const t9 = this.createTileQuery(s9); return t9.objectIds = e3, { tile: s9, query: t9 }; }).map(async ({ tile: e4, query: s9 }) => ({ tile: e4, result: await this.query(s9), query: s9 })), i4 = (await C(t8)).map(async ({ tile: t9, result: r6 }) => { if (!r6.hasFeatures && !s8.length && !e3.length) return; const i5 = this._subscriptions.get(t9.key.id); i5 && i5.edit(r6, e3); }); await E2(i4); } this._didEdit = true; } }; // node_modules/@arcgis/core/views/2d/layers/features/sources/BaseFeatureSource.js var d7 = s.getLogger("esri.views.2d.layers.features.sources.BaseFeatureSource"); var y5 = 4; var h3 = class extends f8 { constructor(e3) { super(e3), this.type = "feature", this.mode = "on-demand", this._adapter = h2(e3.serviceInfo), this._queue = new l2({ concurrency: 8, process: async (e4) => { if (f2(e4), r(e4.tile)) { const t7 = e4.tile.key.id, { signal: s8 } = e4, i4 = a("esri-tiles-debug") ? { tile: t7.replace(/\//g, "."), depth: e4.depth } : void 0, a8 = await this._adapter.executeQuery(e4.query, { signal: s8, query: { ...i4, ...this._schema.customParameters } }); return a8.level = e4.tile.key.level, a8; } return this._adapter.executeQuery(e4.query, { ...e4, query: this._schema.customParameters }); } }), this._patchQueue = new l2({ concurrency: 8, process: async (e4) => { if (f2(e4), r(e4.tile)) { const t7 = e4.tile.key.id, { signal: s8 } = e4, i4 = a("esri-tiles-debug") ? { tile: t7.replace(/\//g, "."), depth: e4.depth } : void 0, a8 = await this._adapter.executeQuery(e4.query, { signal: s8, query: { ...i4, ...this._schema.customParameters } }); return a8.level = e4.tile.key.level, a8; } return this._adapter.executeQuery(e4.query, { ...e4, query: this._schema.customParameters }); } }); } destroy() { super.destroy(), this._adapter.destroy(), this._queue.destroy(), this._patchQueue.destroy(); } get updating() { return !!this._queue.length || Array.from(this._subscriptions.values()).some((e3) => !e3.done); } get maxRecordCountFactor() { const { query: e3 } = this._serviceInfo.capabilities; return e3.supportsMaxRecordCountFactor ? y5 : null; } get maxPageSize() { const { query: e3 } = this._serviceInfo.capabilities; return (e3.maxRecordCount ?? 8e3) * c(this.maxRecordCountFactor, 1); } get pageSize() { return Math.min(8e3, this.maxPageSize); } enableEvent(e3, t7) { } subscribe(e3, r5) { super.subscribe(e3, r5); const s8 = this._subscriptions.get(e3.id); this._fetchDataTile(e3).catch((r6) => { g2(r6) || d7.error(new s2("mapview-query-error", "Encountered error when fetching tile", { tile: e3, error: r6 })); }).then(() => s8.end()); } unsubscribe(e3) { super.unsubscribe(e3); } readers(e3) { return this._subscriptions.get(e3).readers(); } async query(e3) { return this._adapter.executeQuery(e3, { query: this._schema.customParameters }); } async queryLastEditDate() { const t7 = this._serviceInfo.source, r5 = { ...t7.query, f: "json" }; return (await U(t7.path, { query: r5, responseType: "json" })).data.editingInfo.lastEditDate; } createTileQuery(e3, t7 = {}) { const s8 = this._serviceInfo.geometryType, i4 = this.createQuery(t7); i4.quantizationParameters = t7.quantizationParameters ?? e3.getQuantizationParameters(), i4.resultType = "tile", i4.geometry = e3.extent, this._serviceInfo.capabilities.query.supportsQuantization ? s8 === "esriGeometryPolyline" && (i4.maxAllowableOffset = e3.resolution * a("feature-polyline-generalization-factor")) : s8 !== "esriGeometryPolyline" && s8 !== "esriGeometryPolygon" || (i4.maxAllowableOffset = e3.resolution, s8 === "esriGeometryPolyline" && (i4.maxAllowableOffset *= a("feature-polyline-generalization-factor"))); const a8 = this._serviceInfo.capabilities.query; return i4.defaultSpatialReferenceEnabled = a8.supportsDefaultSpatialReference, i4.compactGeometryEnabled = a8.supportsCompactGeometry, i4; } async _executePatchQuery(e3, t7, r5, s8) { const a8 = t7.clone(); a8.outFields = [this._serviceInfo.objectIdField, ...r5], a8.returnCentroid = false, a8.returnGeometry = false; const o11 = r(a8.start) ? a8.start / 8e3 : 0, n6 = s8.signal; return this._patchQueue.push({ tile: e3, query: a8, signal: n6, depth: o11 }); } async _resend(e3, t7) { const { query: r5, message: s8 } = e3, a8 = r(r5.outFields) ? r5.outFields : [], u5 = this._queryInfo.outFields, c12 = u5.filter((e4) => !a8.includes(e4)); if (t(s8.addOrUpdate)) this._onMessage({ ...s8, type: "append" }); else if (c12.length) try { const e4 = this._subscriptions.get(s8.id).tile, i4 = await this._executePatchQuery(e4, r5, c12, t7); f2(t7), r5.outFields = u5, s8.addOrUpdate.joinAttributes(i4), this._onMessage({ ...s8, end: s8.end, type: "append" }); } catch (l9) { } else this._onMessage({ ...s8, type: "append" }); } async _resendSubscription(e3) { if (a("esri-2d-update-debug") && console.debug(e3.tile.id, "Resend Subscription"), e3.empty) return this._onMessage({ id: e3.tile.id, addOrUpdate: null, end: false, type: "append" }); const t7 = e3.signal; for (const r5 of e3.requests.done) await this._resend(r5, { signal: t7 }); return r(e3.edits) ? this._onMessage(e3.edits) : void 0; } async resend() { const e3 = Array.from(this._subscriptions.values()); await Promise.all(e3.map((e4) => this._resendSubscription(e4))); } }; // node_modules/@arcgis/core/views/2d/layers/features/sources/DrillDownFeatureSource.js var i3 = a("esri-mobile"); var a5 = { maxDrillLevel: i3 ? 1 : 4, maxRecordCountFactor: i3 ? 1 : 3 }; var o9 = class extends h3 { constructor(e3) { super(e3); } async _fetchDataTile(e3) { const s8 = this._serviceInfo.capabilities.query.supportsMaxRecordCountFactor, i4 = this._subscriptions.get(e3.key.id), o11 = i4.signal, n6 = e3.getQuantizationParameters(); let c12 = 0; const d11 = async (u5, l9) => { const p5 = this._queryInfo, m7 = this.createTileQuery(u5, { maxRecordCountFactor: s8 ? a5.maxRecordCountFactor : void 0, returnExceededLimitFeatures: false, quantizationParameters: n6 }); c12++; try { const r5 = await this._queue.push({ tile: e3, query: m7, signal: o11, depth: l9 }); if (c12--, f2(o11), !r5) return; if (p5 !== this._queryInfo) return void d11(u5, l9); if (r5.exceededTransferLimit && l9 < a5.maxDrillLevel) { for (const e4 of u5.createChildTiles()) d11(e4, l9 + 1); return; } const s9 = { id: e3.id, addOrUpdate: r5, end: c12 === 0, type: "append" }; i4.add({ query: m7, message: s9 }), this._onMessage(s9); } catch (h6) { g2(h6) || this._onMessage({ id: e3.id, addOrUpdate: null, end: true, type: "append" }); } }; d11(e3, 0); } }; // node_modules/@arcgis/core/layers/graphics/data/StreamFeatureManager.js var o10 = "__esri_stream_id__"; var d8 = "__esri_timestamp__"; var a6 = 1e3; var h4 = class { constructor(t7, e3, s8, i4, r5 = 128) { this._trackIdToObservations = new Map(), this._idCounter = 0, this._lastPurge = performance.now(), this._addOrUpdated = new Map(), this._removed = [], this._maxAge = 0, this._timeInfo = s8, this._purgeOptions = i4, this.store = t7, this.objectIdField = e3, this.purgeInterval = r5, this._useGeneratedIds = this.objectIdField === o10; } add(r5) { if (this._useGeneratedIds) { const t7 = this._nextId(); r5.attributes[this.objectIdField] = t7, r5.objectId = t7; } else r5.objectId = r5.attributes[this.objectIdField]; if (this._addOrUpdated.set(r5.objectId, r5), this._maxAge = Math.max(this._maxAge, r5.attributes[this._timeInfo.startTimeField]), !this._timeInfo.trackIdField) return t(this._trackIdLessObservations) && (this._trackIdLessObservations = new s7(1e5)), void this._trackIdLessObservations.enqueue(r5.objectId); const o11 = r5.attributes[this._timeInfo.trackIdField]; if (!this._trackIdToObservations.has(o11)) { const s8 = r(this._purgeOptions) && this._purgeOptions.maxObservations != null ? this._purgeOptions.maxObservations : a6, r6 = o3(s8, 0, a6); this._trackIdToObservations.set(o11, new s7(r6)); } const d11 = this._trackIdToObservations.get(o11).enqueue(r5.objectId); r(d11) && (this._addOrUpdated.has(d11) ? this._addOrUpdated.delete(d11) : this._removed.push(d11)); } checkForUpdates() { const t7 = this._getToAdd(), e3 = this._getToRemove(), s8 = performance.now(); s8 - this._lastPurge >= this.purgeInterval && (this._purge(s8), this._lastPurge = s8); const r5 = []; if (r(e3)) for (const o11 of e3) { const t8 = this.store.removeById(o11); r(t8) && r5.push(t8); } if (r(t7)) for (const i4 of t7) i4.attributes[d8] = s8, this.store.add(i4); (t7 || r5) && this.store.update(t7, r5); } _getToAdd() { if (!this._addOrUpdated.size) return null; const t7 = new Array(this._addOrUpdated.size); let e3 = 0; return this._addOrUpdated.forEach((s8) => t7[e3++] = s8), this._addOrUpdated.clear(), t7; } _getToRemove() { const t7 = this._removed; return this._removed.length ? (this._removed = [], t7) : null; } _nextId() { const t7 = this._idCounter; return this._idCounter = (this._idCounter + 1) % 4294967294 + 1, t7; } _purge(t7) { const e3 = this._purgeOptions; r(e3) && (this._purgeSomeByDisplayCount(e3), this._purgeByAge(e3), this._purgeByAgeReceived(t7, e3), this._purgeTracks()); } _purgeSomeByDisplayCount(t7) { if (!t7.displayCount) return; let e3 = this.store.size; if (e3 > t7.displayCount) { if (this._timeInfo.trackIdField) { for (const s8 of this._trackIdToObservations.values()) if (e3 > t7.displayCount && s8.size) { const t8 = e2(s8.dequeue()); this._removed.push(t8), e3--; } } if (r(this._trackIdLessObservations)) { let s8 = e3 - t7.displayCount; for (; s8-- > 0; ) { const t8 = this._trackIdLessObservations.dequeue(); r(t8) && this._removed.push(t8); } } } } _purgeByAge(t7) { if (!t7.age || !this._timeInfo?.startTimeField) return; const e3 = 60 * t7.age * 1e3, s8 = this._maxAge - e3; this.store.forEach((t8) => { t8.attributes[this._timeInfo.startTimeField] < s8 && this._removed.push(t8.objectId); }); } _purgeByAgeReceived(t7, e3) { if (!e3.ageReceived) return; const s8 = t7 - 60 * e3.ageReceived * 1e3; this.store.forEach((t8) => { t8.attributes[d8] < s8 && this._removed.push(t8.objectId); }); } _purgeTracks() { this._trackIdToObservations.forEach((t7, e3) => { t7.size === 0 && this._trackIdToObservations.delete(e3); }); } }; // node_modules/@arcgis/core/layers/graphics/sources/connections/StreamConnection.js var t5 = class extends n2.EventedMixin(d4) { onFeature(r5) { this.emit("feature", r5); } }; t5 = e([n("esri.layers.graphics.sources.connections.StreamConnection")], t5); var c7 = t5; // node_modules/@arcgis/core/layers/graphics/sources/connections/WebSocketConnection.js var p2 = s.getLogger("esri.layers.graphics.sources.connections.WebSocketConnection"); var u; !function(e3) { e3[e3.CONNECTING = 0] = "CONNECTING", e3[e3.OPEN = 1] = "OPEN", e3[e3.CLOSING = 2] = "CLOSING", e3[e3.CLOSED = 3] = "CLOSED"; }(u || (u = {})); var m5 = class extends c7 { constructor(e3) { super(), this.errorString = null; const { geometryType: t7, spatialReference: o11, sourceSpatialReference: r5 } = e3; this._config = e3, this._featureZScaler = o4(t7, r5, o11), this._open(); } async _open() { await this._tryCreateWebSocket(), this.destroyed || await this._handshake(); } destroy() { r(this._websocket) && (this._websocket.onopen = null, this._websocket.onclose = null, this._websocket.onerror = null, this._websocket.onmessage = null, this._websocket.close()), this._websocket = null; } get connectionStatus() { if (t(this._websocket)) return "disconnected"; switch (this._websocket.readyState) { case u.CONNECTING: case u.OPEN: return "connected"; case u.CLOSING: case u.CLOSED: return "disconnected"; } } async _tryCreateWebSocket(e3 = this._config.source.path, o11 = 1e3, r5 = 0) { try { if (this.destroyed) return; const t7 = Bt(e3, this._config.customParameters); this._websocket = await this._createWebSocket(t7), this.notifyChange("connectionStatus"); } catch (s8) { const c12 = o11 / 1e3; return this._config.maxReconnectionAttempts && r5 >= this._config.maxReconnectionAttempts ? (p2.error(new s2("websocket-connection", "Exceeded maxReconnectionAttempts attempts. No further attempts will be made")), void this.destroy()) : (p2.error(new s2("websocket-connection", `Failed to connect. Attempting to reconnect in ${c12}s`, s8)), await L(o11), this._tryCreateWebSocket(e3, Math.min(1.5 * o11, 1e3 * this._config.maxReconnectionInterval), r5 + 1)); } } _createWebSocket(e3) { return new Promise((t7, o11) => { const r5 = new WebSocket(e3); r5.onopen = () => { if (r5.onopen = null, this.destroyed) return r5.onclose = null, void r5.close(); r5.onclose = (e4) => this._onClose(e4), r5.onerror = (e4) => this._onError(e4), r5.onmessage = (e4) => this._onMessage(e4), t7(r5); }, r5.onclose = (e4) => { r5.onopen = r5.onclose = null, o11(e4); }; }); } async _handshake(e3 = 1e4) { const o11 = this._websocket; if (t(o11)) return; const r5 = D(), n6 = o11.onmessage, { filter: i4, outFields: a8, spatialReference: l9 } = this._config; return r5.timeout(e3), o11.onmessage = (e4) => { let s8 = null; try { s8 = JSON.parse(e4.data); } catch (c12) { } s8 && typeof s8 == "object" || (p2.error(new s2("websocket-connection", "Protocol violation. Handshake failed - malformed message", e4.data)), r5.reject(), this.destroy()), s8.spatialReference?.wkid !== l9?.wkid && (p2.error(new s2("websocket-connection", `Protocol violation. Handshake failed - expected wkid of ${l9.wkid}`, e4.data)), r5.reject(), this.destroy()), s8.format !== "json" && (p2.error(new s2("websocket-connection", "Protocol violation. Handshake failed - format is not set", e4.data)), r5.reject(), this.destroy()), i4 && s8.filter !== i4 && p2.error(new s2("websocket-connection", "Tried to set filter, but server doesn't support it")), a8 && s8.outFields !== a8 && p2.error(new s2("websocket-connection", "Tried to set outFields, but server doesn't support it")), o11.onmessage = n6, r5.resolve(); }, o11.send(JSON.stringify({ filter: i4, outFields: a8, format: "json", spatialReference: { wkid: l9.wkid } })), r5.promise; } _onMessage(e3) { try { const o11 = JSON.parse(e3.data); if (o11.type !== "featureResult") throw new s2("websocket-connection", "Protocol violation - Expected to find message of type 'featureResult'", o11); for (const e4 of o11.features) r(this._featureZScaler) && this._featureZScaler(e4.geometry), this.onFeature(e4); } catch (o11) { return p2.error(new s2("websocket-connection", "Failed to parse message", o11)), void this.destroy(); } } _onError(e3) { const t7 = "Encountered an error over WebSocket connection"; this._set("errorString", t7), p2.error("websocket-connection", t7); } _onClose(e3) { this._websocket = null, this.notifyChange("connectionStatus"), e3.code !== 1e3 && p2.error("websocket-connection", `WebSocket closed unexpectedly with error code ${e3.code}`), this.destroyed || this._open(); } }; e([d()], m5.prototype, "connectionStatus", null), e([d()], m5.prototype, "errorString", void 0), m5 = e([n("esri.layers.graphics.sources.connections.WebSocketConnection")], m5); // node_modules/@arcgis/core/layers/graphics/sources/connections/GeoEventConnection.js var p3 = s.getLogger("esri.layers.graphics.sources.connections.GeoEventConnection"); var g6 = 1e4; var _2 = { maxQueryDepth: 5, maxRecordCountFactor: 3 }; var w3 = class extends m5 { constructor(e3) { super({ ..._2, ...e3 }); } async _open() { const e3 = await this._fetchServiceDefinition(this._config.source); e3.timeInfo.trackIdField || p3.warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect."); const t7 = this._fetchWebSocketUrl(e3.streamUrls, this._config.spatialReference); this._buddyServicesQuery || (this._buddyServicesQuery = this._queryBuddyServices()), await this._buddyServicesQuery, await this._tryCreateWebSocket(t7); const { filter: r5, outFields: o11 } = this._config; this.destroyed || this._setFilter(r5, o11); } _onMessage(e3) { let t7; try { t7 = this._enrich(JSON.parse(e3.data)), r(this._featureZScaler) && this._featureZScaler(t7.geometry); } catch (o11) { return void p3.error(new s2("geoevent-connection", "Failed to parse message", o11)); } this.onFeature(t7); } async _fetchServiceDefinition(e3) { const r5 = { f: "json", ...this._config.customParameters }, o11 = U(e3.path, { query: r5, responseType: "json" }), s8 = (await o11).data; return this._serviceDefinition = s8, s8; } _fetchWebSocketUrl(e3, t7) { const r5 = e3[0], { urls: o11, token: s8 } = r5, i4 = this._inferWebSocketBaseUrl(o11); return Bt(`${i4}/subscribe`, { outSR: "" + t7.wkid, token: s8 }); } _inferWebSocketBaseUrl(e3) { if (e3.length === 1) return e3[0]; for (const t7 of e3) if (t7.includes("wss")) return t7; return p3.error(new s2("geoevent-connection", "Unable to infer WebSocket url", e3)), null; } async _setFilter(e3, t7) { const o11 = this._websocket; if (t(o11) || t(e3) && t(t7)) return; const s8 = JSON.stringify({ filter: this._serializeFilter(e3, t7) }); let n6 = false; const a8 = D(), u5 = () => { n6 || (this.destroyed || this._websocket !== o11 || p3.error(new s2("geoevent-connection", "Server timed out when setting filter")), a8.reject()); }, f10 = (e4) => { const t8 = JSON.parse(e4.data); t8.filter && (t8.error && (p3.error(new s2("geoevent-connection", "Failed to set service filter", t8.error)), this._set("errorString", `Could not set service filter - ${t8.error}`), a8.reject(t8.error)), o11.onmessage = this._onMessage.bind(this), n6 = true, a8.resolve()); }; return o11.onmessage = f10, o11.send(s8), setTimeout(u5, g6), a8.promise; } _serializeFilter(e3, t7) { const o11 = {}; if (t(e3) && t(t7)) return o11; if (r(e3) && e3.geometry) try { const t8 = d2(e3.geometry); if (t8.type !== "extent") throw new s2(`Expected extent but found type ${t8.type}`); o11.geometry = JSON.stringify(t8.shiftCentralMeridian()); } catch (n6) { p3.error(new s2("geoevent-connection", "Encountered an error when setting connection geometryDefinition", n6)); } return r(e3) && e3.where && e3.where !== "1 = 1" && (o11.where = e3.where), r(t7) && (o11.outFields = t7.join(",")), o11; } _enrich(e3) { if (!this._relatedFeatures) return e3; const t7 = this._serviceDefinition.relatedFeatures.joinField, o11 = e3.attributes[t7]; if (!this._relatedFeatures.has(o11)) return p3.warn("geoevent-connection", "Feature join failed. Is the join field configured correctly?", e3), e3; const { attributes: s8, geometry: i4 } = this._relatedFeatures.get(o11); for (const r5 in s8) e3.attributes[r5] = s8[r5]; return i4 && (e3.geometry = i4), e3.geometry || e3.centroid || p3.error(new s2("geoevent-connection", "Found malformed feature - no geometry found", e3)), e3; } async _queryBuddyServices() { try { const { relatedFeatures: e3, keepLatestArchive: t7 } = this._serviceDefinition, r5 = this._queryRelatedFeatures(e3), o11 = this._queryArchive(t7); await r5; const s8 = await o11; if (!s8) return; for (const i4 of s8.features) this.onFeature(this._enrich(i4)); } catch (e3) { p3.error(new s2("geoevent-connection", "Encountered an error when querying buddy services", { error: e3 })); } } async _queryRelatedFeatures(e3) { if (!e3) return; const t7 = await this._queryBuddy(e3.featuresUrl); this._addRelatedFeatures(t7); } async _queryArchive(e3) { if (e3) return this._queryBuddy(e3.featuresUrl); } async _queryBuddy(e3) { const t7 = new (await import("./FeatureLayer-TEDDRCNO.js")).default({ url: e3 }), { capabilities: r5 } = await t7.load(), o11 = r5.query.supportsMaxRecordCountFactor, s8 = r5.query.supportsPagination, i4 = r5.query.supportsCentroid, c12 = this._config.maxRecordCountFactor, u5 = t7.capabilities.query.maxRecordCount, f10 = o11 ? u5 * c12 : u5, d11 = new b3(); if (d11.outFields = c(this._config.outFields, ["*"]), d11.where = c(m(this._config.filter, "where"), "1=1"), d11.returnGeometry = true, d11.returnExceededLimitFeatures = true, d11.outSpatialReference = k.fromJSON(this._config.spatialReference), i4 && (d11.returnCentroid = true), o11 && (d11.maxRecordCountFactor = c12), s8) return d11.num = f10, t7.destroy(), this._queryPages(e3, d11); const y8 = await c3(e3, d11, this._config.sourceSpatialReference); return t7.destroy(), y8.data; } async _queryPages(e3, t7, r5 = [], o11 = 0) { t7.start = r(t7.num) ? o11 * t7.num : null; const { data: i4 } = await c3(e3, t7, this._config.sourceSpatialReference); return i4.exceededTransferLimit && o11 < this._config.maxQueryDepth ? (i4.features.forEach((e4) => r5.push(e4)), this._queryPages(e3, t7, r5, o11 + 1)) : (r5.forEach((e4) => i4.features.push(e4)), i4); } _addRelatedFeatures(e3) { const t7 = new Map(), r5 = e3.features, o11 = this._serviceDefinition.relatedFeatures.joinField; for (const s8 of r5) { const e4 = s8.attributes[o11]; t7.set(e4, s8); } this._relatedFeatures = t7; } }; w3 = e([n("esri.layers.graphics.sources.connections.GeoEventConnection")], w3); var F3 = w3; // node_modules/@arcgis/core/layers/graphics/sources/connections/createConnection.js function t6(t7, o11, r5, c12, i4, s8, a8, m7) { const p5 = t7.path.indexOf("wss://") === 0 || t7.path.indexOf("ws://") === 0, f10 = { source: t7, sourceSpatialReference: o11, spatialReference: r5, geometryType: c12, filter: i4, maxReconnectionAttempts: s8, maxReconnectionInterval: a8, customParameters: m7 }; return p5 ? new m5(f10) : new F3(f10); } // node_modules/@arcgis/core/views/2d/layers/features/sources/GeoEventSource.js var m6 = 2500; function l7(t7, s8) { const r5 = t7.weakClone(); if (r(t7.geometry)) { const e3 = b2(s8, t7.geometry.coords[0]), i4 = M2(s8, t7.geometry.coords[1]); r5.geometry = new t3([], [e3, i4]); } return r5; } function _3(e3) { return e3 === "esriGeometryPoint" ? l7 : (t7, s8) => { const r5 = t7.weakClone(), n6 = new t3(), o11 = false, c12 = false, d11 = ie(n6, t7.geometry, o11, c12, e3, s8, false, false); return r5.geometry = d11, r5; }; } function f9(t7) { return t7 === "esriGeometryPoint" ? (t8) => r(t8.geometry) ? { minX: t8.geometry.coords[0], minY: t8.geometry.coords[1], maxX: t8.geometry.coords[0], maxY: t8.geometry.coords[1] } : { minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 } : (t8) => { let s8 = 1 / 0, r5 = 1 / 0, i4 = -1 / 0, n6 = -1 / 0; return r(t8.geometry) && t8.geometry.forEachVertex((e3, t9) => { s8 = Math.min(s8, e3), r5 = Math.min(r5, t9), i4 = Math.max(i4, e3), n6 = Math.max(n6, t9); }), { minX: s8, minY: r5, maxX: i4, maxY: n6 }; }; } function g7(e3, t7) { const r5 = i(9, f9(t7)); return r5.load(e3), r5; } function v4(e3, t7) { return e3.search({ minX: t7.bounds[0], minY: t7.bounds[1], maxX: t7.bounds[2], maxY: t7.bounds[3] }); } var y6 = class { constructor(e3, t7) { this.onUpdate = e3, this._geometryType = t7, this._objectIdToFeature = new Map(); } get _features() { const e3 = []; return this._objectIdToFeature.forEach((t7) => e3.push(t7)), e3; } add(e3) { this._objectIdToFeature.set(e3.objectId, e3), this._index = null; } get(e3) { return this._objectIdToFeature.has(e3) ? this._objectIdToFeature.get(e3) : null; } forEach(e3) { this._objectIdToFeature.forEach(e3); } search(e3) { return this._index || (this._index = g7(this._features, this._geometryType)), v4(this._index, e3); } removeById(e3) { const t7 = this._objectIdToFeature.get(e3); return t7 ? (this._objectIdToFeature.delete(e3), this._index = null, t7) : null; } update(e3, t7) { this.onUpdate(e3, t7); } get size() { return this._objectIdToFeature.size; } }; var b4 = class extends f8 { constructor(e3) { super(e3), this.type = "geoevent", this._dataReceiveEventEnabled = false, this._level = 0, this._updateInfo = { websocket: 0, client: 0 }; const { outSR: s8 } = e3, { geometryType: r5, objectIdField: i4, timeInfo: n6, purgeOptions: o11, source: a8, spatialReference: u5, serviceFilter: h6, maxReconnectionAttempts: p5, maxReconnectionInterval: l9, updateInterval: f10, enableDataReceived: g9, customParameters: v5 } = e3.serviceInfo, b5 = new y6(this._onUpdate.bind(this), r5), I2 = new h4(b5, i4, n6, o11), j4 = t6(a8, u5, s8, r5, h6, p5, l9, v5); this._store = b5, this._manager = I2, this._connection = j4, this._quantize = _3(r5), this._dataReceiveEventEnabled = g9, this._handles = [this._connection.on("feature", (e4) => this._onFeature(e4)), l(() => j4.connectionStatus, (e4) => this.events.emit("connectionStatus", e4)), l(() => j4.errorString, (e4) => this.events.emit("errorString", e4))], this._initUpdateInterval = () => { let t7 = performance.now(); this._updateIntervalId = setInterval(() => { const s9 = performance.now(), r6 = s9 - t7; if (r6 > m6) { t7 = s9; const e4 = Math.round(this._updateInfo.client / (r6 / 1e3)), i5 = Math.round(this._updateInfo.websocket / (r6 / 1e3)); this._updateInfo.client = 0, this._updateInfo.websocket = 0, this.events.emit("updateRate", { client: e4, websocket: i5 }); } e3.canAcceptRequest() && this._manager.checkForUpdates(); }, f10); }, this._initUpdateInterval(); } destroy() { super.destroy(), this._clearUpdateInterval(), this._handles.forEach((e3) => e3.remove()), this._connection.destroy(); } _fetchDataTile() { } pauseStream() { this._clearUpdateInterval(); } resumeStream() { this._initUpdateInterval(); } enableEvent(e3, t7) { e3 === "data-received" && (this._dataReceiveEventEnabled = t7); } get updating() { return false; } subscribe(e3, t7) { super.subscribe(e3, t7); const s8 = this._subscriptions.get(e3.id); this._level = e3.level; const r5 = this._getTileFeatures(e3); this._onMessage({ type: "append", id: e3.key.id, addOrUpdate: r5, end: true }), s8.didSend = true; } unsubscribe(e3) { super.unsubscribe(e3); } *readers(t7) { const s8 = this._subscriptions.get(t7), { tile: r5 } = s8; yield this._getTileFeatures(r5); for (const i4 of s8.requests.stream.entries) r(i4) && r(i4.addOrUpdate) && (yield i4.addOrUpdate); } createTileQuery(e3) { throw new Error("Service does not support tile queries"); } async resend() { this._subscriptions.forEach((e3) => { const { tile: t7 } = e3, s8 = { type: "append", id: t7.id, addOrUpdate: this._getTileFeatures(t7), end: true }; this._onMessage(s8); }); } _getTileFeatures(e3) { const t7 = this._store.search(e3).map((t8) => this._quantize(t8, e3.transform)); return d5.fromOptimizedFeatures(t7, this._serviceInfo, e3.transform); } _onFeature(e3) { this._updateInfo.websocket++; try { this._dataReceiveEventEnabled && this.events.emit("feature", e3); const t7 = Q(e3, this._serviceInfo.geometryType, false, false, this._serviceInfo.objectIdField); this._manager.add(t7); } catch (t7) { } } _clearUpdateInterval() { clearInterval(this._updateIntervalId), this._updateIntervalId = 0; } _onUpdate(t7, s8) { r(t7) && (this._updateInfo.client += t7.length), this._subscriptions.forEach((e3, t8) => { e3.didSend && e3.tile.level === this._level && this._onMessage({ type: "append", id: t8, addOrUpdate: null, clear: true, end: false }); }), this._subscriptions.forEach((e3, t8) => { if (!e3.didSend || e3.tile.level !== this._level) return; const s9 = e3.tile, r5 = { type: "append", id: t8, addOrUpdate: this._getTileFeatures(s9), remove: [], end: true, status: t4.empty() }; e3.requests.stream.enqueue(r5), this._onMessage(r5); }); } }; // node_modules/@arcgis/core/views/2d/layers/features/sources/PagedFeatureSource.js var n5 = s.getLogger("esri.views.2d.layers.features.sources.FeatureSource"); var d9 = class extends h3 { constructor(e3) { super(e3); } async _fetchDataTile(t7) { const r5 = 6, i4 = 20, o11 = this._subscriptions.get(t7.key.id); let d11 = false, c12 = 0, u5 = 0; const p5 = (e3, r6) => { u5--, f2(o11); const a8 = t7.id, i5 = e3.reader, n6 = e3.query; if (!i5.exceededTransferLimit) { if (d11 = true, r6 !== 0 && !i5.hasFeatures) { const e5 = { id: a8, addOrUpdate: i5, end: u5 === 0, type: "append" }; return o11.add({ message: e5, query: n6 }), void this._onMessage(e5); } const e4 = { id: a8, addOrUpdate: i5, end: u5 === 0, type: "append" }; return o11.add({ message: e4, query: n6 }), void this._onMessage(e4); } const c13 = { id: a8, addOrUpdate: i5, end: d11 && u5 === 0, type: "append" }; o11.add({ message: c13, query: n6 }), this._onMessage(c13); }; let h6 = 0, m7 = 0; for (; !d11 && m7++ < i4; ) { let i5; for (let r6 = 0; r6 < h6 + 1; r6++) { const r7 = c12++; u5++, i5 = this._fetchDataTilePage(t7, r7, o11).then((e3) => e3 && p5(e3, r7)).catch((r8) => { d11 = true, g2(r8) || (n5.error(new s2("mapview-query-error", "Encountered error when fetching tile", { tile: t7, error: r8 })), this._onMessage({ id: t7.id, addOrUpdate: null, end: d11, type: "append" })); }); } await i5, f2(o11), h6 = Math.min(h6 + 2, r5); } } async _fetchDataTilePage(e3, t7, a8) { f2(a8); const o11 = this._queryInfo, n6 = { start: this.pageSize * t7, num: this.pageSize, returnExceededLimitFeatures: true, quantizationParameters: e3.getQuantizationParameters() }; r(this.maxRecordCountFactor) && (n6.maxRecordCountFactor = this.maxRecordCountFactor); const d11 = this.createTileQuery(e3, n6); try { const r5 = a8.signal, i4 = await this._queue.push({ tile: e3, query: d11, signal: r5, depth: t7 }); return f2(a8), i4 ? o11 !== this._queryInfo ? this._fetchDataTilePage(e3, t7, a8) : { reader: i4, query: d11 } : null; } catch (c12) { return b(c12), null; } } }; // node_modules/@arcgis/core/views/2d/layers/features/sources/SnapshotFeatureSource.js var u2 = s.getLogger("esri.views.2d.layers.features.sources.SnapshotFeatureSource"); function l8(t7, e3, s8) { const r5 = t7.getXHydrated(), o11 = t7.getYHydrated(), a8 = e3.getColumnForX(r5), i4 = Math.floor(e3.normalizeCol(a8)); return `${s8}/${Math.floor(e3.getRowForY(o11))}/${i4}`; } function c8(t7, e3) { if (t(t7)) return null; const s8 = e3.transform, o11 = t7.getQuantizationTransform(); if (t(o11)) { const [e4, r5] = s8.scale, [o12, a9] = s8.translate, i5 = -o12 / e4, n7 = 1 / e4, d12 = a9 / r5, h7 = 1 / -r5; return t7.transform(i5, d12, n7, h7); } const [a8, i4] = o11.scale, [n6, d11] = o11.translate, [h6, u5] = s8.scale, [l9, c12] = s8.translate, g9 = a8 / h6, p5 = (n6 - l9) / h6, _4 = i4 / u5, m7 = (-d11 + c12) / u5; return t7.transform(p5, m7, g9, _4); } var g8 = class extends h3 { constructor(t7) { super(t7), this.mode = "snapshot", this._loading = true, this._controller = new AbortController(), this._downloadPromise = null, this._didSendEnd = false, this._queries = new Array(), this._invalidated = false, this._hasAggregates = false, this._random = new t2(1e3), this._store = t7.store, this._markedIdsBufId = this._store.storage.createBitset(); } destroy() { super.destroy(), this._controller.abort(); } get loading() { return this._loading; } get _signal() { return this._controller.signal; } update(t7, e3) { super.update(t7, e3), this._hasAggregates = t7.targets.aggregate; } async resend(t7 = false) { if (await this._downloadPromise, this._invalidated || t7) { const t8 = f(this._schema.featureCount, "Expected featureCount to be defined"); return this._invalidated = false, this._subscriptions.forEach((t9) => t9.clear()), this._downloadPromise = this._download(t8), void await this._downloadPromise; } const s8 = this._queries.map(({ query: t8, reader: e3 }) => this._sendPatchQuery(t8, e3)); await Promise.all(s8), this._subscriptions.forEach((t8) => { t8.requests.done.forEach((t9) => this._onMessage(t9.message)); }); } async refresh() { await this.resend(true); } async _sendPatchQuery(t7, e3) { const r5 = r(t7.outFields) ? t7.outFields : [], a8 = this._queryInfo.outFields, i4 = a8.filter((t8) => !r5.includes(t8)); if (!i4.length) return; const n6 = t7.clone(), d11 = this._signal; n6.returnGeometry = false, n6.returnCentroid = false, n6.outFields = i4, t7.outFields = a8; const h6 = await this._queue.push({ query: n6, depth: 0, signal: d11 }); f2({ signal: d11 }), e3.joinAttributes(h6); } async _fetchDataTile(t7) { if (!this._downloadPromise) { const t8 = f(this._schema.featureCount, "Expected featureCount to be defined"); this._downloadPromise = this._download(t8); } const s8 = this._store.search(t7), r5 = this._subscriptions.get(t7.key.id), o11 = s8.length - 1; for (let e3 = 0; e3 < o11; e3++) { const o12 = c8(s8[e3], t7), i5 = { type: "append", id: t7.id, addOrUpdate: o12, end: false, status: t4.empty() }; r5.add({ query: null, message: i5 }), this._hasAggregates || await L(1), this._onMessage(i5); } const i4 = c8(o11 >= 0 ? s8[o11] : null, t7), n6 = this._didSendEnd, d11 = { type: "append", id: t7.id, addOrUpdate: i4, end: n6, status: t4.empty() }; r5.add({ query: null, message: d11 }), this._onMessage(d11); } async _download(t7) { try { await this.whenInitialized(); const e3 = this._store.storage.getBitset(this._markedIdsBufId), s8 = new Set(); e3.clear(); const r5 = Math.ceil(t7 / this.pageSize), o11 = Array.from({ length: r5 }, (t8, e4) => e4).sort((t8, e4) => this._random.getInt() - this._random.getInt()).map((t8) => this._downloadPage(t8, e3, s8)); await Promise.all(o11), this._store.sweepFeatures(e3, this._store.storage), this._store.sweepFeatureSets(s8); } catch (e3) { u2.error("mapview-snapshot-source", "Encountered and error when downloading feature snapshot", e3); } this._sendEnd(), this._loading = false; } async _downloadPage(t7, e3, r5) { const a8 = this.pageSize, i4 = { start: t7 * a8, num: a8, cacheHint: true }; r(this.maxRecordCountFactor) && (i4.maxRecordCountFactor = this.maxRecordCountFactor); const n6 = this.createQuery(i4), d11 = this._signal, h6 = await this._queue.push({ query: n6, depth: t7, signal: d11 }); f2({ signal: d11 }), this._queries.push({ query: n6, reader: h6 }), this._store.insert(h6), r5.add(h6.instance); const u5 = h6.getCursor(); for (; u5.next(); ) e3.set(u5.getDisplayId()); this._send(h6); } _send(t7) { if (!this._subscriptions.size) return; let e3 = null; const o11 = new Map(), a8 = new Set(), i4 = new Map(); this._subscriptions.forEach((t8) => { const s8 = t8.tile; o11.set(s8.key.id, null), e3 = s8.tileInfoView, a8.add(s8.level); const { row: r5, col: n6 } = s8.key, d11 = `${s8.level}/${r5}/${n6}`, h6 = i4.get(d11) ?? []; h6.push(t8), i4.set(d11, h6); }); for (const s8 of a8) { const a9 = e3.getLODInfoAt(s8), n6 = t7.getCursor(); for (; n6.next(); ) { const t8 = l8(n6, a9, s8), e4 = n6.getIndex(); if (i4.has(t8)) for (const s9 of i4.get(t8)) { const t9 = s9.tile.id; let a10 = o11.get(t9); t(a10) && (a10 = [], o11.set(t9, a10)), a10.push(e4); } } } o11.forEach((e4, r5) => { if (r(e4)) { const s8 = this._subscriptions.get(r5), o12 = { type: "append", id: r5, addOrUpdate: c8(r2.from(t7, e4), s8.tile), end: false, status: t4.empty() }; s8.add({ query: null, message: o12 }), this._onMessage(o12); } }); } _sendEnd() { this._subscriptions.forEach((t7) => { const e3 = { type: "append", id: t7.tile.id, addOrUpdate: null, end: true, status: t4.empty() }; t7.add({ query: null, message: e3 }), this._onMessage(e3); }), this._didSendEnd = true; } }; // node_modules/@arcgis/core/views/2d/layers/features/sources/createSource.js function a7(e3, r5, a8, u5, i4, p5) { const f10 = c9(e3, r5, a8, u5, i4, p5); switch (f10.type) { case "feature": switch (f10.origin) { case "hosted": case "local": return new d9(f10); case "snapshot": return new g8(f10); case "unknown": return new o9(f10); } case "geoevent": return new b4(f10); } } function c9(t7, o11, n6, s8, a8, c12) { switch (t7.type) { case "snapshot": return { type: "feature", origin: "snapshot", featureCount: c(t7.featureCount, 0), serviceInfo: t7, onMessage: s8, outSR: o11, tileInfoView: n6, canAcceptRequest: a8, store: c12 }; case "stream": return { type: "geoevent", serviceInfo: t7, onMessage: s8, outSR: o11, canAcceptRequest: a8 }; case "memory": case "on-demand": return { type: "feature", serviceInfo: t7, onMessage: s8, outSR: o11, origin: u5(t7.source), tileInfoView: n6, canAcceptRequest: a8 }; } function u5(e3) { return Array.isArray(e3) ? "local" : "path" in e3 && g4(e3.path) ? "hosted" : "unknown"; } } // node_modules/@arcgis/core/geohash/geohashUtils.js var c10 = new Float64Array(2); var h5 = new Float64Array(2); function x2(t7, n6) { let o11 = -90, e3 = 90, r5 = -180, c12 = 180; for (let h6 = 0; h6 < n6; h6++) { const n7 = Math.ceil((h6 + 1) / 2), f10 = Math.floor((h6 + 1) / 2), l9 = 1 - h6 % 2, a8 = 30 - (3 * n7 + 2 * f10), u5 = 30 - (2 * n7 + 3 * f10), s8 = 3 * l9 + 2 * (1 - l9), i4 = 2 * l9 + 3 * (1 - l9), M4 = 3 * l9 + 7 * (1 - l9) << u5, g9 = (7 * l9 + 3 * (1 - l9) << a8 & t7.geohashX) >> a8, b5 = (M4 & t7.geohashY) >> u5; for (let t8 = s8 - 1; t8 >= 0; t8--) { const n8 = (r5 + c12) / 2, o12 = g9 & 1 << t8 ? 1 : 0; r5 = (1 - o12) * r5 + o12 * n8, c12 = (1 - o12) * n8 + o12 * c12; } for (let t8 = i4 - 1; t8 >= 0; t8--) { const n8 = (o11 + e3) / 2, r6 = b5 & 1 << t8 ? 1 : 0; o11 = (1 - r6) * o11 + r6 * n8, e3 = (1 - r6) * n8 + r6 * e3; } } return [r5, o11, c12, e3]; } function y7(t7, n6, o11, e3) { e3 % 2 && (e3 += 1); let r5 = 0, c12 = 0, h6 = -90, f10 = 90, l9 = -180, a8 = 180; for (let u5 = 0; u5 < e3 / 2; u5++) { for (let t8 = 0; t8 < 5; t8++) { const n7 = (l9 + a8) / 2, e4 = o11 > n7 ? 1 : 0; r5 |= e4 << 29 - (t8 + 5 * u5), l9 = (1 - e4) * l9 + e4 * n7, a8 = (1 - e4) * n7 + e4 * a8; } for (let t8 = 0; t8 < 5; t8++) { const o12 = (h6 + f10) / 2, e4 = n6 > o12 ? 1 : 0; c12 |= e4 << 29 - (t8 + 5 * u5), h6 = (1 - e4) * h6 + e4 * o12, f10 = (1 - e4) * o12 + e4 * f10; } } t7.geohashX = r5, t7.geohashY = c12; } function p4(t7, n6, o11, e3, r5) { r5 % 2 && (r5 += 1); let c12 = 0, h6 = 0, f10 = -90, l9 = 90, a8 = -180, u5 = 180; for (let s8 = 0; s8 < r5 / 2; s8++) { for (let t8 = 0; t8 < 5; t8++) { const n7 = (a8 + u5) / 2, o12 = e3 > n7 ? 1 : 0; c12 |= o12 << 29 - (t8 + 5 * s8), a8 = (1 - o12) * a8 + o12 * n7, u5 = (1 - o12) * n7 + o12 * u5; } for (let t8 = 0; t8 < 5; t8++) { const n7 = (f10 + l9) / 2, e4 = o11 > n7 ? 1 : 0; h6 |= e4 << 29 - (t8 + 5 * s8), f10 = (1 - e4) * f10 + e4 * n7, l9 = (1 - e4) * n7 + e4 * l9; } } t7[2 * n6] = c12, t7[2 * n6 + 1] = h6; } // node_modules/@arcgis/core/geohash/GeohashTree.js var c11 = class { constructor(e3 = [], s8, i4 = 8096) { this.onRelease = (t7) => { }, this._nodes = 0, this._root = new u3(this, 0, 0, 0), this._statisticFields = e3, this._pool = i4 ? new s7(8096) : null, this._serviceInfo = s8; } destroy() { this.clear(); } _acquire(t7, s8, i4) { this._nodes++; let o11 = null; return r(this._pool) && (o11 = this._pool.dequeue()), r(o11) ? o11.realloc(t7, s8, i4) : o11 = new u3(this, t7, s8, i4), o11; } _release(t7) { this.onRelease(t7), this._nodes--, r(this._pool) && this._pool.enqueue(t7); } get count() { return this._root.count; } get size() { return this._nodes; } get poolSize() { return E(this._pool, 0, (t7) => t7.size); } get depth() { let t7 = 0; return this.forEach((e3) => t7 = Math.max(t7, e3.depth)), t7; } dropLevels(t7) { this.forEach((e3) => { if (e3.depth >= t7) for (let t8 = 0; t8 < e3.children.length; t8++) { const s8 = e3.children[t8]; s8 && this._release(s8); } }), this.forEach((e3) => { if (e3.depth >= t7) for (let t8 = 0; t8 < e3.children.length; t8++) e3.children[t8] = null; }); } clear() { this.forEach((t7) => this._release(t7)), this._root = new u3(this, 0, 0, 0); } insert(t7, e3, s8 = 0) { const i4 = d5.fromOptimizedFeatures([t7], this._serviceInfo).getCursor(); i4.next(); const o11 = i4.readGeometry(); if (!o11) return; const [n6, a8] = o11.coords, r5 = t7.geohashX, l9 = t7.geohashY; this.insertCursor(i4, t7.displayId, n6, a8, r5, l9, e3, s8); } insertCursor(t7, e3, s8, i4, o11, n6, a8, r5 = 0) { let l9 = this._root, h6 = 0, c12 = 0, u5 = 0; for (; l9 !== null; ) { if (l9.depth >= r5 && (l9.count += 1, l9.xTotal += s8, l9.yTotal += i4, l9.xGeohashTotal += o11, l9.yGeohashTotal += n6, l9.referenceId = e3, this._updateStatisticsCursor(t7, l9, 1)), h6 >= a8) return void l9.add(e3); const d11 = Math.ceil((h6 + 1) / 2), f10 = Math.floor((h6 + 1) / 2), x5 = 1 - h6 % 2, m7 = 30 - (3 * d11 + 2 * f10), p5 = 30 - (2 * d11 + 3 * f10), g9 = (o11 & 7 * x5 + 3 * (1 - x5) << m7) >> m7, y8 = (n6 & 3 * x5 + 7 * (1 - x5) << p5) >> p5, _4 = g9 + y8 * (8 * x5 + 4 * (1 - x5)); c12 = c12 << 3 * x5 + 2 * (1 - x5) | g9, u5 = u5 << 2 * x5 + 3 * (1 - x5) | y8, l9.children[_4] == null && (l9.children[_4] = this._acquire(c12, u5, h6 + 1)), h6 += 1, l9 = l9.children[_4]; } } remove(t7, e3) { const s8 = d5.fromOptimizedFeatures([t7], this._serviceInfo).getCursor(); s8.next(); const i4 = s8.readGeometry(); if (!i4) return; const [o11, n6] = i4.coords, a8 = t7.geohashX, r5 = t7.geohashY; this.removeCursor(s8, o11, n6, a8, r5, e3); } removeCursor(t7, e3, s8, i4, o11, n6) { let a8 = this._root, r5 = 0; for (; a8 !== null; ) { if (a8.count -= 1, a8.xTotal -= e3, a8.yTotal -= s8, a8.xGeohashTotal -= i4, a8.yGeohashTotal -= o11, this._updateStatisticsCursor(t7, a8, -1), r5 >= n6) return void a8.remove(t7.getDisplayId()); const l9 = Math.ceil((r5 + 1) / 2), h6 = Math.floor((r5 + 1) / 2), c12 = 1 - r5 % 2, u5 = 30 - (3 * l9 + 2 * h6), d11 = 30 - (2 * l9 + 3 * h6), f10 = ((i4 & 7 * c12 + 3 * (1 - c12) << u5) >> u5) + ((o11 & 3 * c12 + 7 * (1 - c12) << d11) >> d11) * (8 * c12 + 4 * (1 - c12)), x5 = a8.children[f10]; x5.count === 1 && (this._release(x5), a8.children[f10] = null), r5 += 1, a8 = x5; } } forEach(t7) { let e3 = this._root; for (; e3 !== null; ) { const s8 = this._linkChildren(e3) || e3.next; t7(e3), e3 = s8; } } find(t7, e3, s8) { return this._root.find(t7, e3, s8, 0, 0, 0); } findIf(t7) { let e3 = null; return this.forEach((s8) => { t7(s8) && (e3 = s8); }), e3; } findAllIf(t7) { const e3 = []; return this.forEach((s8) => { t7(s8) && e3.push(s8); }), e3; } findSingleOccupancyNode(t7, e3, s8, i4, o11) { let n6 = this._root; for (; n6 !== null; ) { const a8 = n6.depth, r5 = n6.xNode, l9 = n6.yNode, h6 = 1 - a8 % 2, c12 = n6.xGeohashTotal / n6.count, u5 = n6.yGeohashTotal / n6.count; if (n6.count === 1 && t7 < c12 && c12 <= s8 && e3 < u5 && u5 <= i4) return n6; if (a8 >= o11) { n6 = n6.next; continue; } const d11 = Math.ceil((a8 + 1) / 2), f10 = Math.floor((a8 + 1) / 2), x5 = 30 - (3 * d11 + 2 * f10), m7 = 30 - (2 * d11 + 3 * f10), p5 = ~((1 << x5) - 1), g9 = ~((1 << m7) - 1), y8 = (t7 & p5) >> x5, _4 = (e3 & g9) >> m7, M4 = (s8 & p5) >> x5, N = (i4 & g9) >> m7, T2 = r5 << 3 * h6 + 2 * (1 - h6), I2 = l9 << 2 * h6 + 3 * (1 - h6), S4 = T2 + 8 * h6 + 4 * (1 - h6), v5 = I2 + 4 * h6 + 8 * (1 - h6), C2 = Math.max(T2, y8), b5 = Math.max(I2, _4), G3 = Math.min(S4, M4), k3 = Math.min(v5, N); let F4 = null, z = null; for (let t8 = b5; t8 <= k3; t8++) for (let e4 = C2; e4 <= G3; e4++) { const s9 = e4 - T2 + (t8 - I2) * (8 * h6 + 4 * (1 - h6)), i5 = n6.children[s9]; i5 && (F4 || (F4 = i5, F4.next = n6.next), z && (z.next = i5), z = i5, i5.next = n6.next); } n6 = F4 || n6.next; } return null; } getRegionDisplayIds(t7, e3, s8, i4, o11) { let n6 = this._root; const a8 = []; for (; n6 !== null; ) { const r5 = n6.depth, l9 = n6.xNode, h6 = n6.yNode; if (r5 >= o11) { const o12 = n6.xGeohashTotal / n6.count, r6 = n6.yGeohashTotal / n6.count; t7 <= o12 && o12 <= s8 && e3 <= r6 && r6 <= i4 && n6.displayIds.forEach((t8) => a8.push(t8)), n6 = n6.next; continue; } const c12 = Math.ceil((r5 + 1) / 2), u5 = Math.floor((r5 + 1) / 2), d11 = 1 - r5 % 2, f10 = 30 - (3 * c12 + 2 * u5), x5 = 30 - (2 * c12 + 3 * u5), m7 = ~((1 << f10) - 1), p5 = ~((1 << x5) - 1), g9 = (t7 & m7) >> f10, y8 = (e3 & p5) >> x5, _4 = (s8 & m7) >> f10, M4 = (i4 & p5) >> x5, N = l9 << 3 * d11 + 2 * (1 - d11), T2 = h6 << 2 * d11 + 3 * (1 - d11), I2 = N + 8 * d11 + 4 * (1 - d11), S4 = T2 + 4 * d11 + 8 * (1 - d11), v5 = Math.max(N, g9), C2 = Math.max(T2, y8), b5 = Math.min(I2, _4), G3 = Math.min(S4, M4); let k3 = null, F4 = null; for (let t8 = C2; t8 <= G3; t8++) for (let e4 = v5; e4 <= b5; e4++) { const s9 = e4 - N + (t8 - T2) * (8 * d11 + 4 * (1 - d11)), i5 = n6.children[s9]; i5 && (k3 || (k3 = i5, k3.next = n6.next), F4 && (F4.next = i5), F4 = i5, i5.next = n6.next); } n6 = k3 || n6.next; } return a8; } getRegionStatistics(t7, e3, s8, i4, o11) { let n6 = this._root, a8 = 0, r5 = 0, l9 = 0; const h6 = {}; let c12 = 0; for (; n6 !== null; ) { const u5 = n6.depth, d11 = n6.xNode, f10 = n6.yNode; if (u5 >= o11) { const o12 = n6.xGeohashTotal / n6.count, u6 = n6.yGeohashTotal / n6.count; t7 < o12 && o12 <= s8 && e3 < u6 && u6 <= i4 && (a8 += n6.count, r5 += n6.xTotal, l9 += n6.yTotal, n6.count === 1 && (c12 = n6.referenceId), this._aggregateStatistics(h6, n6.statistics)), n6 = n6.next; continue; } const x5 = Math.ceil((u5 + 1) / 2), m7 = Math.floor((u5 + 1) / 2), p5 = 1 - u5 % 2, g9 = 30 - (3 * x5 + 2 * m7), y8 = 30 - (2 * x5 + 3 * m7), _4 = ~((1 << g9) - 1), M4 = ~((1 << y8) - 1), N = (t7 & _4) >> g9, T2 = (e3 & M4) >> y8, I2 = (s8 & _4) >> g9, S4 = (i4 & M4) >> y8, v5 = d11 << 3 * p5 + 2 * (1 - p5), C2 = f10 << 2 * p5 + 3 * (1 - p5), b5 = v5 + 8 * p5 + 4 * (1 - p5), G3 = C2 + 4 * p5 + 8 * (1 - p5), k3 = Math.max(v5, N), F4 = Math.max(C2, T2), z = Math.min(b5, I2), w5 = Math.min(G3, S4); let j4 = null, E4 = null; for (let o12 = F4; o12 <= w5; o12++) for (let u6 = k3; u6 <= z; u6++) { const d12 = u6 - v5 + (o12 - C2) * (8 * p5 + 4 * (1 - p5)), f11 = n6.children[d12]; if (f11) { if (o12 !== F4 && o12 !== w5 && u6 !== k3 && u6 !== z) { const o13 = f11.xGeohashTotal / f11.count, u7 = f11.yGeohashTotal / f11.count; t7 < o13 && o13 <= s8 && e3 < u7 && u7 <= i4 && (a8 += f11.count, r5 += f11.xTotal, l9 += f11.yTotal, n6.count === 1 && (c12 = n6.referenceId), this._aggregateStatistics(h6, f11.statistics)); continue; } j4 || (j4 = f11, j4.next = n6.next), E4 && (E4.next = f11), E4 = f11, f11.next = n6.next; } } n6 = j4 || n6.next; } return { count: a8, attributes: this.normalizeStatistics(h6, a8), xTotal: r5, yTotal: l9, referenceId: c12 }; } getBins(t7, e3, s8, i4, o11) { const n6 = []; let a8 = this._root; for (; a8 !== null; ) { const r5 = a8.depth, l9 = a8.xNode, h6 = a8.yNode; if (r5 >= o11) { n6.push(a8), a8 = a8.next; continue; } const c12 = Math.ceil((r5 + 1) / 2), u5 = Math.floor((r5 + 1) / 2), d11 = 1 - r5 % 2, f10 = 30 - (3 * c12 + 2 * u5), x5 = 30 - (2 * c12 + 3 * u5), m7 = ~((1 << f10) - 1), p5 = ~((1 << x5) - 1), g9 = (t7 & m7) >> f10, y8 = (e3 & p5) >> x5, _4 = (s8 & m7) >> f10, M4 = (i4 & p5) >> x5, N = l9 << 3 * d11 + 2 * (1 - d11), T2 = h6 << 2 * d11 + 3 * (1 - d11), I2 = N + 8 * d11 + 4 * (1 - d11), S4 = T2 + 4 * d11 + 8 * (1 - d11), v5 = Math.max(N, g9), C2 = Math.max(T2, y8), b5 = Math.min(I2, _4), G3 = Math.min(S4, M4); let k3 = null, F4 = null; for (let t8 = C2; t8 <= G3; t8++) for (let e4 = v5; e4 <= b5; e4++) { const s9 = e4 - N + (t8 - T2) * (8 * d11 + 4 * (1 - d11)), i5 = a8.children[s9]; i5 && (k3 || (k3 = i5, k3.next = a8.next), F4 && (F4.next = i5), F4 = i5, i5.next = a8.next); } a8 = k3 || a8.next; } return n6; } _linkChildren(t7) { let e3 = null, s8 = null; for (let i4 = 0; i4 <= t7.children.length; i4++) { const o11 = t7.children[i4]; o11 && (e3 || (e3 = o11, e3.next = t7.next), s8 && (s8.next = o11), s8 = o11, o11.next = t7.next); } return e3; } _updateStatisticsCursor(t7, e3, s8) { for (const i4 of this._statisticFields) { const o11 = i4.name, n6 = i4.inField ? t7.readAttribute(i4.inField) : t7.getComputedNumericAtIndex(i4.inFieldIndex); switch (i4.statisticType) { case "norm": { e3.statistics[o11] || (e3.statistics[o11] = {}); const a8 = i4.inNormalizationField, r5 = t7.readAttribute(a8), l9 = e3.statistics[o11].onStatisticField || 0, h6 = e3.statistics[o11].onStatisticNormalizationField || 0; n6 == null || isNaN(n6) || r5 == null || r5 === 0 || isNaN(r5) || (e3.statistics[o11].onStatisticField = l9 + s8 * n6, e3.statistics[o11].onStatisticNormalizationField = h6 + s8 * r5); break; } case "sum": case "avg": { e3.statistics[o11] || (e3.statistics[o11] = { value: 0, nanCount: 0 }); const t8 = e3.statistics[o11].value, i5 = e3.statistics[o11].nanCount; n6 == null || isNaN(n6) ? e3.statistics[o11].nanCount = i5 + s8 : e3.statistics[o11].value = t8 + s8 * n6; break; } case "avg_angle": { e3.statistics[o11] || (e3.statistics[o11] = { x: 0, y: 0, nanCount: 0 }); const t8 = e3.statistics[o11].x, i5 = e3.statistics[o11].y, a8 = e3.statistics[o11].nanCount, r5 = Math.PI / 180; n6 == null || isNaN(n6) ? e3.statistics[o11].nanCount = a8 + s8 : (e3.statistics[o11].x = t8 + s8 * Math.cos(n6 * r5), e3.statistics[o11].y = i5 + s8 * Math.sin(n6 * r5)); break; } case "mode": { e3.statistics[o11] || (e3.statistics[o11] = {}); const t8 = e3.statistics[o11][n6] || 0; e3.statistics[o11][n6] = t8 + s8; break; } } } } _aggregateStatistics(t7, e3) { for (const s8 of this._statisticFields) { const i4 = s8.name; switch (s8.statisticType) { case "sum": case "avg": case "avg_angle": case "mode": case "norm": t7[i4] || (t7[i4] = {}); for (const s9 in e3[i4]) { const o11 = t7[i4][s9] || 0; t7[i4][s9] = o11 + e3[i4][s9]; } } } } normalizeStatistics(t7, e3) { const s8 = {}; for (const i4 of this._statisticFields) { const o11 = i4.name; switch (i4.statisticType) { case "norm": { const i5 = t7[o11]; if (e3 && i5.onStatisticNormalizationField == null) break; if (e3 && i5.onStatisticNormalizationField) { s8[o11] = i5.onStatisticField / i5.onStatisticNormalizationField; break; } s8[o11] = 0; break; } case "sum": { if (!e3) break; const { value: i5, nanCount: n6 } = t7[o11]; if (!(e3 - n6)) break; s8[o11] = i5; break; } case "avg": { if (!e3) break; const { value: i5, nanCount: n6 } = t7[o11]; if (!(e3 - n6)) break; s8[o11] = i5 / (e3 - n6); break; } case "avg_angle": { if (!e3) break; const { x: i5, y: n6, nanCount: a8 } = t7[o11]; if (!(e3 - a8)) break; const r5 = i5 / (e3 - a8), l9 = n6 / (e3 - a8), h6 = 180 / Math.PI, c12 = Math.atan2(l9, r5) * h6; s8[o11] = c12; break; } case "mode": { const e4 = t7[o11]; let i5 = 0, n6 = null; for (const t8 in e4) { const s9 = e4[t8]; s9 > i5 && (i5 = s9, n6 = t8); } s8[o11] = n6 === "null" ? null : n6; break; } } } return s8; } }; var u3 = class { constructor(t7, e3, s8, i4) { this.count = 0, this.xTotal = 0, this.yTotal = 0, this.statistics = {}, this.displayId = 0, this.referenceId = 0, this.displayIds = new Set(), this.next = null, this.depth = 0, this.xNode = 0, this.yNode = 0, this.xGeohashTotal = 0, this.yGeohashTotal = 0, this._tree = t7, this.children = new Array(32); for (let o11 = 0; o11 < this.children.length; o11++) this.children[o11] = null; this.xNode = e3, this.yNode = s8, this.depth = i4; } realloc(t7, e3, s8) { for (let i4 = 0; i4 < this.children.length; i4++) this.children[i4] = null; return this.xNode = t7, this.yNode = e3, this.depth = s8, this.next = null, this.xGeohashTotal = 0, this.yGeohashTotal = 0, this.displayId = 0, this.referenceId = 0, this.xTotal = 0, this.yTotal = 0, this.count = 0, this.statistics = {}, this.displayIds.clear(), this; } get id() { return `${this.xNode}.${this.yNode}`; } add(t7) { this.displayIds.add(t7); } remove(t7) { this.displayIds.delete(t7); } getAttributes() { const t7 = this._tree.normalizeStatistics(this.statistics, this.count); return t7.aggregateId = this.id, t7.aggregateCount = this.count, t7; } getGeometry(t7, s8) { const i4 = this.getLngLatBounds(), [h6, c12, u5, d11] = i4, f10 = g3({ rings: [[[h6, c12], [h6, d11], [u5, d11], [u5, c12], [h6, c12]]] }, k.WGS84, t7), x5 = D2(new t3(), f10, false, false); return r(s8) ? ie(new t3(), x5, false, false, "esriGeometryPolygon", s8, false, false) : x5; } getLngLatBounds() { const t7 = this.depth, e3 = Math.ceil(t7 / 2), s8 = Math.floor(t7 / 2), o11 = 30 - (3 * e3 + 2 * s8), n6 = 30 - (2 * e3 + 3 * s8), a8 = this.xNode << o11, r5 = this.yNode << n6; return x2({ geohashX: a8, geohashY: r5 }, this.depth); } find(t7, e3, s8, i4, o11, n6) { if (i4 >= s8) return this; const a8 = 1 - i4 % 2, r5 = 3 * a8 + 2 * (1 - a8), l9 = 2 * a8 + 3 * (1 - a8), h6 = 30 - o11 - r5, c12 = 30 - n6 - l9, u5 = ((t7 & 7 * a8 + 3 * (1 - a8) << h6) >> h6) + ((e3 & 3 * a8 + 7 * (1 - a8) << c12) >> c12) * (8 * a8 + 4 * (1 - a8)), d11 = this.children[u5]; return d11 == null ? null : d11.find(t7, e3, s8, i4 + 1, o11 + r5, n6 + l9); } }; // node_modules/@arcgis/core/views/2d/layers/features/support/BinStore.js var G2 = s.getLogger("esri.view.2d.layers.features.support.BinStore"); var B = 12; var L2 = 64; var R3 = 5; function S3(e3) { return 57.29577951308232 * e3; } var A2 = class extends c4 { constructor(e3, t7, s8, r5) { super(e3, s8), this._geohashLevel = R3, this._geohashBuf = [], this._serviceInfo = r5, this.geometryInfo = e3.geometryInfo, this._spatialReference = t7, this._projectionSupportCheck = f4(t7, k.WGS84), this._bitsets.geohash = s8.getBitset(s8.createBitset()), this._bitsets.inserted = s8.getBitset(s8.createBitset()); } destroy() { this._tree && this._tree.destroy(); } async updateSchema(t7, r5) { const i4 = this._schema; try { await super.updateSchema(t7, r5), await this._projectionSupportCheck; } catch (d11) { } const n6 = m2(i4, r5); r5 && (!t(n6) || t7.source || t7.storage.filters) ? ((a3(n6, "params.fields") || a3(n6, "params") || !this._tree || t7.source) && (this._tree && this._tree.destroy(), this._tree = new c11(this._statisticFields, this._serviceInfo), this._tree.onRelease = (e3) => e3.displayId && this._storage.releaseDisplayId(e3.displayId), this._geohashLevel = this._schema.params.fixedBinLevel, this._rebuildTree(), a("esri-2d-update-debug") && G2.info("Aggregate mesh needs update due to tree changing")), a("esri-2d-update-debug") && G2.info("Aggregate mesh needs update due to tree changing"), t7.targets[r5.name] = true, t7.mesh = false) : i4 && (t7.mesh = true); } clear() { this._rebuildTree(); } sweepFeatures(e3, t7) { this._bitsets.inserted.forEachSet((s8) => { if (!e3.has(s8)) { const e4 = t7.lookupByDisplayIdUnsafe(s8); this._remove(e4); } }); } sweepAggregates(e3, t7, s8) { } onTileData(e3, t7, r5, i4, o11 = true) { if (!this._schema || t(t7.addOrUpdate)) return t7; const a8 = this._getTransforms(e3, this._spatialReference); { const e4 = t7.addOrUpdate.getCursor(); for (; e4.next(); ) this._update(e4, i4); } if (t7.status.mesh || !o11) return t7; const h6 = new Array(); this._getBinsForTile(h6, e3, a8, r5), t7.addOrUpdate = d5.fromOptimizedFeatures(h6, { ...this._serviceInfo, geometryType: "esriGeometryPolygon" }), t7.addOrUpdate.attachStorage(r5), t7.clear = true, t7.end = true; { const s8 = t7.addOrUpdate.getCursor(); for (; s8.next(); ) { const t8 = s8.getDisplayId(); this._bitsets.computed.unset(t8), this.setComputedAttributes(r5, s8, t8, e3.scale); } } return t7; } forEach(e3) { this._tree.forEach(e3); } onTileUpdate(e3) { } getAggregate(e3) { const t7 = s6(e3, true), s8 = this._tree.findIf((e4) => e4.displayId === t7); return o(s8, (e4) => this._toAggregateGraphic(e4)); } getAggregates() { return this._tree.findAllIf((e3) => e3.depth === this._geohashLevel).map(this._toAggregateGraphic.bind(this)); } getDisplayId(e3) { const t7 = this._tree.findIf((t8) => t8.id === e3); return o(t7, (e4) => e4.displayId); } getFeatureDisplayIdsForAggregate(e3) { const t7 = this._tree.findIf((t8) => t8.id === e3); return E(t7, [], (e4) => Array.from(e4.displayIds)); } getDisplayIdForReferenceId(e3) { const t7 = this._tree.findIf((t8) => t8.displayIds.size === 1 && t8.displayIds.has(e3)); return o(t7, (e4) => e4.displayId); } _toAggregateGraphic(e3) { const t7 = this._spatialReference; return { referenceId: null, objectId: e3.id, displayId: e3.displayId, attributes: e3.getAttributes(), geometry: ne(e3.getGeometry(t7), "esriGeometryPolygon", false, false), centroid: null }; } _rebuildTree() { this._bitsets.computed.clear(), this._bitsets.inserted.clear(), this._tree && this._tree.clear(); } _remove(e3) { const t7 = e3.getDisplayId(), s8 = e3.getXHydrated(), r5 = e3.getYHydrated(), i4 = this._geohashBuf[2 * t7], o11 = this._geohashBuf[2 * t7 + 1]; this._bitsets.inserted.has(t7) && (this._bitsets.inserted.unset(t7), this._tree.removeCursor(e3, s8, r5, i4, o11, this._geohashLevel)); } _update(e3, t7) { const s8 = e3.getDisplayId(), r5 = this._bitsets.inserted, i4 = t7.isVisible(s8); if (i4 === r5.has(s8)) return; if (!i4) return void this._remove(e3); const o11 = e3.getXHydrated(), a8 = e3.getYHydrated(); if (!this._setGeohash(s8, o11, a8)) return; const h6 = this._geohashBuf[2 * s8], n6 = this._geohashBuf[2 * s8 + 1]; this._tree.insertCursor(e3, s8, o11, a8, h6, n6, this._geohashLevel), r5.set(s8); } _setGeohash(e3, t7, s8) { if (this._bitsets.geohash.has(e3)) return true; const r5 = this._geohashBuf; if (this._spatialReference.isWebMercator) { const i4 = S3(t7 / s3.radius), o11 = i4 - 360 * Math.floor((i4 + 180) / 360), a8 = S3(Math.PI / 2 - 2 * Math.atan(Math.exp(-s8 / s3.radius))); p4(r5, e3, a8, o11, B); } else { const i4 = g3({ x: t7, y: s8 }, this._spatialReference, k.WGS84); if (!i4) return false; p4(r5, e3, i4.y, i4.x, B); } return this._bitsets.geohash.set(e3), true; } _getBinsForTile(e3, t7, s8, r5) { try { const { xLL: i4, yLL: o11, xTR: a8, yTR: h6, level: n6 } = this._getGeohashBounds(t7), d11 = this._tree.getBins(i4, o11, a8, h6, n6); for (const t8 of d11) { t8.displayId || (t8.displayId = r5.createDisplayId(true)); const i5 = t8.getGeometry(this._spatialReference, s8.tile), o12 = new s4(i5, t8.getAttributes()); o12.objectId = t8.id, o12.displayId = t8.displayId, e3.push(o12); } } catch (i4) { return void G2.error("Unable to get bins for tile", t7.key.id); } } _getGeohash(e3, t7, s8) { const r5 = { geohashX: 0, geohashY: 0 }; return y7(r5, t7, e3, s8), r5; } _getGeohashBounds(e3) { const t7 = this._getGeohashLevel(e3.key.level), s8 = [e3.extent.xmin, e3.extent.ymin, e3.extent.xmax, e3.extent.ymax], r5 = v.fromExtent(M.fromBounds(s8, this._spatialReference)), i4 = g3(r5, this._spatialReference, k.WGS84, { densificationStep: e3.resolution * L2 }), o11 = D2(new t3(), i4, false, false), a8 = o11.coords.filter((e4, t8) => !(t8 % 2)), h6 = o11.coords.filter((e4, t8) => t8 % 2), n6 = Math.min(...a8), d11 = Math.min(...h6), g9 = Math.max(...a8), p5 = Math.max(...h6), l9 = this._getGeohash(n6, d11, t7), u5 = this._getGeohash(g9, p5, t7); return { xLL: l9.geohashX, yLL: l9.geohashY, xTR: u5.geohashX, yTR: u5.geohashY, level: t7 }; } _getGeohashLevel(e3) { return this._schema.params.fixedBinLevel; } _getTransforms(e3, t7) { const s8 = { originPosition: "upperLeft", scale: [e3.resolution, e3.resolution], translate: [e3.bounds[0], e3.bounds[3]] }, r5 = R(t7); if (!r5) return { tile: s8, left: null, right: null }; const [i4, o11] = r5.valid; return { tile: s8, left: { ...s8, translate: [o11, e3.bounds[3]] }, right: { ...s8, translate: [i4 - o11 + e3.bounds[0], e3.bounds[3]] } }; } }; // node_modules/@arcgis/core/views/2d/layers/features/support/ClusterStore.js var M3 = 12; var x3 = 1; var L3 = class extends o2 { constructor(e3, t7, s8, r5, i4) { super(new t3([], [t7, s8]), r5, null, e3), this.geohashBoundsInfo = i4; } get count() { return this.attributes.cluster_count; } static create(e3, t7, s8, r5, i4, a8, o11, h6) { const l9 = new L3(t7, s8, r5, a8, o11); return l9.displayId = e3.createDisplayId(true), l9.referenceId = h6, l9.tileLevel = i4, l9; } update(e3, t7, s8, r5, i4, a8) { return this.geometry.coords[0] = e3, this.geometry.coords[1] = t7, this.tileLevel = s8, this.attributes = r5, this.geohashBoundsInfo = i4, this.referenceId = null, this.referenceId = a8, this; } toJSON() { return { objectId: this.objectId, referenceId: this.attributes.cluster_count === 1 ? this.referenceId : null, attributes: { ...this.attributes, clusterId: this.objectId }, geometry: { x: this.geometry.coords[0], y: this.geometry.coords[1] } }; } }; function j3(e3) { return 57.29577951308232 * e3; } var w4 = class extends c4 { constructor(t7, s8, r5, i4) { super(t7, r5), this.events = new n2(), this._geohashLevel = 0, this._tileLevel = 0, this._aggregateValueRanges = {}, this._aggregateValueRangesChanged = false, this._geohashBuf = [], this._clusters = new Map(), this._tiles = new Map(), this._serviceInfo = i4, this.geometryInfo = t7.geometryInfo, this._spatialReference = s8, this._projectionSupportCheck = f4(s8, k.WGS84), this._bitsets.geohash = r5.getBitset(r5.createBitset()), this._bitsets.inserted = r5.getBitset(r5.createBitset()); } destroy() { this._tree.destroy(); } async updateSchema(e3, r5) { const i4 = this._schema; try { await super.updateSchema(e3, r5), await this._projectionSupportCheck; } catch (n6) { } const l9 = m2(i4, r5); r5 && (!t(l9) || e3.source || e3.storage.filters) ? ((a3(l9, "params.fields") || !this._tree || e3.source) && (this._tree && this._tree.destroy(), this._tree = new c11(this._statisticFields, this._serviceInfo), this._rebuildTree(), a("esri-2d-update-debug") && console.debug("Aggregate mesh needs update due to tree changing")), a("esri-2d-update-debug") && console.debug("Applying Update - ClusterStore:", l9), e3.targets[r5.name] = true, e3.mesh = false, this._aggregateValueRanges = {}) : i4 && (e3.mesh = true); } clear() { this._rebuildTree(); } sweepFeatures(e3, t7) { this._bitsets.inserted.forEachSet((s8) => { if (!e3.has(s8)) { const e4 = t7.lookupByDisplayIdUnsafe(s8); this._remove(e4); } }); } sweepAggregates(e3, t7, s8) { this._clusters.forEach((r5, i4) => { r5 && r5.tileLevel !== s8 && (e3.releaseDisplayId(r5.displayId), t7.unsetAttributeData(r5.displayId), this._clusters.delete(i4)); }); } onTileData(e3, t7, r5, i4, a8 = true) { if (!this._schema || t(t7.addOrUpdate)) return t7; const o11 = this._getTransforms(e3, this._spatialReference); { const e4 = t7.addOrUpdate.getCursor(); for (; e4.next(); ) this._update(e4, i4); } if (t7.status.mesh || !a8) return t7; const h6 = new Array(), l9 = this._schema.params.clusterRadius; this._getClustersForTile(h6, e3, l9, r5, o11), t7.addOrUpdate = d5.fromOptimizedFeatures(h6, this._serviceInfo), t7.addOrUpdate.attachStorage(r5), t7.clear = true, t7.end = true; { const s8 = t7.addOrUpdate.getCursor(); for (; s8.next(); ) { const t8 = s8.getDisplayId(); this._bitsets.computed.unset(t8), this.setComputedAttributes(r5, s8, t8, e3.scale); } } return this._aggregateValueRangesChanged && t7.end && (this.events.emit("valueRangesChanged", { valueRanges: this._aggregateValueRanges }), this._aggregateValueRangesChanged = false), t7; } onTileUpdate({ added: e3, removed: t7 }) { if (e3.length) { const t8 = e3[0].level; this._tileLevel = t8, this._setGeohashLevel(t8); } if (!this._schema) return; const s8 = this._schema.params.clusterRadius; t7.forEach((e4) => { this._tiles.delete(e4.key.id), this._markTileClustersForDeletion(e4, s8); }); } getAggregate(e3) { for (const t7 of this._clusters.values()) if ((t7?.displayId & n3) == (e3 & n3)) return t7.toJSON(); return null; } getAggregates() { const e3 = []; for (const t7 of this._clusters.values()) t7?.tileLevel === this._tileLevel && e3.push(t7.toJSON()); return e3; } getDisplayId(e3) { const t7 = this._clusters.get(e3); return t7 ? t7.displayId : null; } getFeatureDisplayIdsForAggregate(e3) { const t7 = this._clusters.get(e3); if (!t7) return []; const s8 = t7.geohashBoundsInfo; return this._tree.getRegionDisplayIds(s8.xLL, s8.yLL, s8.xTR, s8.yTR, s8.level); } getDisplayIdForReferenceId(e3) { for (const t7 of this._clusters.values()) if (t7?.referenceId === e3) return t7.displayId; return null; } getAggregateValueRanges() { return this._aggregateValueRanges; } forEach(e3) { for (const [t7, s8] of this._clusters) s8 && e3(s8, t7); } size() { let e3 = 0; return this.forEach((t7) => e3++), e3; } _rebuildTree() { this._bitsets.computed.clear(), this._bitsets.inserted.clear(), this._tree && this._tree.clear(); } _remove(e3) { const t7 = e3.getDisplayId(), s8 = e3.getXHydrated(), r5 = e3.getYHydrated(), i4 = this._geohashBuf[2 * t7], a8 = this._geohashBuf[2 * t7 + 1]; this._bitsets.inserted.has(t7) && (this._bitsets.inserted.unset(t7), this._tree.removeCursor(e3, s8, r5, i4, a8, this._geohashLevel)); } _update(e3, t7) { const s8 = e3.getDisplayId(), r5 = this._bitsets.inserted, i4 = t7.isVisible(s8); if (i4 === r5.has(s8)) return; if (!i4) return void this._remove(e3); const a8 = e3.getXHydrated(), o11 = e3.getYHydrated(); if (!this._setGeohash(s8, a8, o11)) return; const h6 = this._geohashBuf[2 * s8], l9 = this._geohashBuf[2 * s8 + 1]; this._tree.insertCursor(e3, s8, a8, o11, h6, l9, this._geohashLevel), r5.set(s8); } _setGeohash(e3, t7, s8) { if (this._bitsets.geohash.has(e3)) return true; const r5 = this._geohashBuf; if (this._spatialReference.isWebMercator) { const i4 = j3(t7 / s3.radius), a8 = i4 - 360 * Math.floor((i4 + 180) / 360), o11 = j3(Math.PI / 2 - 2 * Math.atan(Math.exp(-s8 / s3.radius))); p4(r5, e3, o11, a8, M3); } else { const i4 = g3({ x: t7, y: s8 }, this._spatialReference, k.WGS84); if (!i4) return false; p4(r5, e3, i4.y, i4.x, M3); } return this._bitsets.geohash.set(e3), true; } _getClustersForTile(e3, t7, a8, o11, h6, l9 = true) { const n6 = this._schema.params.clusterPixelBuffer, u5 = 2 * a8, c12 = this._getGeohashLevel(t7.key.level), f10 = Math.ceil(2 ** t7.key.level * o5 / u5), _4 = Math.ceil(n6 / u5) + 0, m7 = Math.ceil(o5 / u5), { row: y8, col: v5 } = t7.key, b5 = v5 * o5, R5 = y8 * o5, C2 = Math.floor(b5 / u5) - _4, M4 = Math.floor(R5 / u5) - _4, x5 = C2 + m7 + 2 * _4, L4 = M4 + m7 + 2 * _4, j4 = t7.tileInfoView.getLODInfoAt(t7.key.level); for (let I2 = C2; I2 <= x5; I2++) for (let a9 = M4; a9 <= L4; a9++) { let n7 = I2; j4.wrap && (n7 = I2 < 0 ? I2 + f10 : I2 % f10); const u6 = j4.wrap && I2 < 0, _5 = j4.wrap && I2 % f10 !== I2, m8 = this._lookupCluster(o11, j4, t7.key.level, n7, a9, c12); if (r(m8)) { const t8 = o(h6, (e4) => u6 ? e4.left : _5 ? e4.right : e4.tile); if (l9 && t(t8)) continue; if (!m8.count) continue; if (r(t8) && l9) { const s8 = m8.geometry.clone(); let i4 = m8.attributes; s8.coords[0] = b2(t8, s8.coords[0]), s8.coords[1] = M2(t8, s8.coords[1]), m8.count === 1 && r(m8.referenceId) && (i4 = { ...m8.attributes, referenceId: m8.referenceId }); const a10 = new s4(s8, i4); a10.displayId = m8.displayId, e3.push(a10); } } } } _getGeohashLevel(e3) { return Math.min(Math.ceil(e3 / 2 + 2), M3); } _setGeohashLevel(e3) { const t7 = this._getGeohashLevel(e3), s8 = (Math.floor(t7 / x3) + 1) * x3 - 1; if (this._geohashLevel !== s8) return this._geohashLevel = s8, this._rebuildTree(), void this._bitsets.geohash.clear(); } _getTransforms(e3, t7) { const s8 = { originPosition: "upperLeft", scale: [e3.resolution, e3.resolution], translate: [e3.bounds[0], e3.bounds[3]] }, r5 = R(t7); if (!r5) return { tile: s8, left: null, right: null }; const [i4, a8] = r5.valid; return { tile: s8, left: { ...s8, translate: [a8, e3.bounds[3]] }, right: { ...s8, translate: [i4 - a8 + e3.bounds[0], e3.bounds[3]] } }; } _getClusterId(e3, t7, s8) { return (15 & e3) << 28 | (16383 & t7) << 14 | 16383 & s8; } _markForDeletion(e3, t7, s8) { const r5 = this._getClusterId(e3, t7, s8); this._clusters.delete(r5); } _getClusterBounds(e3, t7, s8) { const r5 = this._schema.params.clusterRadius, i4 = 2 * r5; let a8 = s8 % 2 ? t7 * i4 : t7 * i4 - r5; const o11 = s8 * i4; let h6 = a8 + i4; const l9 = o11 - i4, n6 = 2 ** e3.level * o5; e3.wrap && a8 < 0 && (a8 = 0), e3.wrap && h6 > n6 && (h6 = n6); const u5 = a8 / o5, c12 = o11 / o5, g9 = h6 / o5, d11 = l9 / o5; return [e3.getXForColumn(u5), e3.getYForRow(c12), e3.getXForColumn(g9), e3.getYForRow(d11)]; } _lookupCluster(e3, t7, s8, i4, a8, o11) { const h6 = this._getClusterId(s8, i4, a8), l9 = this._clusters.get(h6), [c12, g9, d11, f10] = this._getClusterBounds(t7, i4, a8), p5 = { x: c12, y: g9 }, _4 = { x: d11, y: f10 }; let m7 = 0, I2 = 0, v5 = 0, b5 = 0; if (this._spatialReference.isWebMercator) { { const e4 = j3(p5.x / s3.radius); m7 = e4 - 360 * Math.floor((e4 + 180) / 360), I2 = j3(Math.PI / 2 - 2 * Math.atan(Math.exp(-p5.y / s3.radius))); } { const e4 = j3(_4.x / s3.radius); v5 = e4 - 360 * Math.floor((e4 + 180) / 360), b5 = j3(Math.PI / 2 - 2 * Math.atan(Math.exp(-_4.y / s3.radius))); } } else { const e4 = g3(p5, this._spatialReference, k.WGS84), t8 = g3(_4, this._spatialReference, k.WGS84); if (!e4 || !t8) return null; m7 = e4.x, I2 = e4.y, v5 = t8.x, b5 = t8.y; } const R5 = { geohashX: 0, geohashY: 0 }, M4 = { geohashX: 0, geohashY: 0 }; y7(R5, I2, m7, o11), y7(M4, b5, v5, o11); const x5 = R5.geohashX, w5 = R5.geohashY, V = M4.geohashX, S4 = M4.geohashY, F4 = { xLL: x5, yLL: w5, xTR: V, yTR: S4, level: o11 }, D3 = this._tree.getRegionStatistics(x5, w5, V, S4, o11), { count: T2, xTotal: k3, yTotal: B2, referenceId: A4 } = D3, G3 = T2 ? k3 / T2 : 0, O2 = T2 ? B2 / T2 : 0; if (T2 === 0) return this._clusters.set(h6, null), null; const U3 = { cluster_count: T2, ...D3.attributes }, X = r(l9) ? l9.update(G3, O2, s8, U3, F4, A4) : L3.create(e3, h6, G3, O2, s8, U3, F4, A4); return T2 === 0 && (X.geometry.coords[0] = (c12 + d11) / 2, X.geometry.coords[1] = (g9 + f10) / 2), this._clusters.set(h6, X), this._updateAggregateValueRangeForCluster(X, X.tileLevel), X; } _updateAggregateValueRangeForCluster(e3, t7) { const s8 = this._aggregateValueRanges[t7] || { minValue: 1 / 0, maxValue: 0 }, r5 = s8.minValue, i4 = s8.maxValue; s8.minValue = Math.min(r5, e3.count), s8.maxValue = Math.max(i4, e3.count), this._aggregateValueRanges[t7] = s8, r5 === s8.minValue && i4 === s8.maxValue || (this._aggregateValueRangesChanged = true); } _markTileClustersForDeletion(e3, t7) { const s8 = 2 * t7, r5 = Math.ceil(o5 / s8), { row: i4, col: a8 } = e3.key, o11 = a8 * o5, h6 = i4 * o5, l9 = Math.floor(o11 / s8), n6 = Math.floor(h6 / s8); for (let u5 = l9; u5 < l9 + r5; u5++) for (let t8 = n6; t8 < n6 + r5; t8++) this._markForDeletion(e3.key.level, u5, t8); } }; // node_modules/@arcgis/core/views/2d/layers/features/controllers/FeatureController2D.js var T = 5e3; var k2 = "tileRenderer.featuresView.attributeView.initialize"; var q3 = "tileRenderer.featuresView.attributeView.requestUpdate"; var R4 = "tileRenderer.featuresView.requestRender"; function U2(e3) { return e3.name === "worker:port-closed"; } function x4(e3) { if (!g2(e3) && !U2(e3)) throw e3; } function Q2(e3) { return e3.type === "feature" && e3.mode === "snapshot"; } var O = class extends d4 { constructor() { super(...arguments), this._storage = new r3(), this._markedIdsBufId = this._storage.createBitset(), this._lastCleanup = performance.now(), this._cleanupNeeded = false, this._invalidated = false, this._tileToResolver = new Map(), this._didEdit = false, this._updateVersion = 1, this.tileStore = null, this.config = null, this.processor = null, this.remoteClient = null, this.service = null; } initialize() { this._initStores(), this._initSource(), this._updateQueue = new l2({ concurrency: this._source.type === "geoevent" ? 1 : 4, process: (e3, t7) => this._onTileMessage(e3, { signal: t7 }) }), this.handles.add([this.tileStore.on("update", this.onTileUpdate.bind(this)), f3(() => !this.updating, () => this.onIdle())]), this._checkUpdating = setInterval(() => this.notifyChange("updating"), 300); } _initSource() { const e3 = this.tileStore.tileScheme, t7 = () => this._updateQueue.length < 50, r5 = (e4, t8) => (this._invalidated = true, this._patchTile(e4, t8)); this._source = a7(this.service, this.spatialReference, e3, r5, t7, this.featureStore), this._proxyEvents(); } _proxyEvents() { if (this._source.type === "geoevent") { const e3 = this._source.events; this.handles.add([e3.on("connectionStatus", (e4) => this.remoteClient.invoke("setProperty", { propertyName: "connectionStatus", value: e4 }).catch(x4)), e3.on("errorString", (e4) => this.remoteClient.invoke("setProperty", { propertyName: "errorString", value: e4 }).catch(x4)), e3.on("feature", (e4) => this.remoteClient.invoke("emitEvent", { name: "data-received", event: { attributes: e4.attributes, centroid: e4.centroid, geometry: e4.geometry } }).catch(x4)), e3.on("updateRate", (e4) => this.remoteClient.invoke("emitEvent", { name: "update-rate", event: { ...e4 } }).catch(x4))]); } } _initAttributeStore(e3) { this.attributeStore ? this.attributeStore.invalidateResources() : this.attributeStore = new R2({ type: "remote", initialize: (e4, t7) => j(this.remoteClient.invoke(k2, e4, { signal: t7 }).catch(x4)), update: (e4, t7) => j(this.remoteClient.invoke(q3, e4, { signal: t7 }).catch(x4)), render: (e4) => j(this.remoteClient.invoke(R4, void 0, { signal: e4 }).catch(x4)) }, e3, () => this.notifyChange("updating")); } _initStores() { const e3 = this.service.type === "snapshot" ? "snapshot" : "on-demand", t7 = { geometryInfo: { geometryType: this.service.geometryType, hasM: false, hasZ: false }, spatialReference: this.spatialReference, fieldsIndex: this.fieldsIndex, fields: this.service.fields }; this.featureStore = new l3(t7, this._storage, e3); } _initQueryEngine(e3) { const t7 = this; this.queryEngine?.destroy(), this.queryEngine = new Y({ definitionExpression: e3.schema.source.definitionExpression, fields: this.service.fields, geometryType: this.service.geometryType, objectIdField: this.service.objectIdField, hasM: false, hasZ: false, spatialReference: this.spatialReference.toJSON(), cacheSpatialQueries: true, featureStore: this.featureStore, aggregateAdapter: { getFeatureObjectIds(e4) { if (t(t7.aggregateStore)) return []; return t7.aggregateStore.getFeatureDisplayIdsForAggregate(e4).map((e5) => t7.getObjectId(e5)); } }, timeInfo: this.service.timeInfo }); } destroy() { this._updateQueue.destroy(), this._source.destroy(), this.queryEngine.destroy(), this.attributeStore && this.attributeStore.destroy(); for (const e3 of this.tileStore.tiles) this._source.unsubscribe(e3); clearInterval(this._checkUpdating); } get fieldsIndex() { return new d3(this.service.fields); } get spatialReference() { return this.tileStore.tileScheme.spatialReference; } get updating() { return this.isUpdating(); } isUpdating() { const e3 = this._source.updating, t7 = !!this._updateQueue.length, s8 = !this.attributeStore || this.attributeStore.isUpdating(), i4 = e3 || t7 || s8; return a("esri-2d-log-updating") && console.log(`Updating FeatureController2D: ${i4} -> updatingSource ${e3} -> updateQueue ${t7} -> updatingAttributeStore ${s8} `), i4; } enableEvent(e3) { this._source.enableEvent(e3.name, e3.value); } pause() { this._updateQueue.pause(), this._updateQueue.clear(); } resume() { this._updateQueue.resume(); } pauseStream() { this._source.type === "geoevent" && this._source.pauseStream(); } resumeStream() { this._source.type === "geoevent" && this._source.resumeStream(); } _initAggregateStore(e3) { const t7 = { geometryInfo: { geometryType: this.service.geometryType, hasM: false, hasZ: false }, spatialReference: this.spatialReference, fieldsIndex: this.fieldsIndex, fields: this.service.fields }, r5 = e3.schema.targets?.aggregate?.type, s8 = o(this.config, (e4) => e4.schema.targets?.aggregate?.type); if (s8 !== r5 && (r(this.aggregateStore) && (this.handles.remove("valueRangesChanged"), this.aggregateStore.destroy(), this.aggregateStore = null), r5)) { switch (r5) { case "cluster": this.aggregateStore = new w4(t7, this.spatialReference, this._storage, this.service), this.handles.add(this.aggregateStore.events.on("valueRangesChanged", (e4) => { this.remoteClient.invoke("emitEvent", { name: "valueRangesChanged", event: { valueRanges: e4.valueRanges } }).catch(x4); }), "valueRangesChanged"); break; case "bin": this.aggregateStore = new A2(t7, this.spatialReference, this._storage, this.service); } this.aggregateStore.onTileUpdate({ added: this.tileStore.tiles, removed: [] }); } } async update(e3, t7) { this._updateVersion++, this._initQueryEngine(t7), this._initAttributeStore(t7), this.pause(), await Promise.all([this._source.update(e3, t7.schema.source), this.featureStore.updateSchema(e3, t7.schema.targets.feature), this.attributeStore.update(e3, t7), this.attributeStore.updateFilters(e3, t7, this)]), this._initAggregateStore(t7), r(this.aggregateStore) && await this.aggregateStore.updateSchema(e3, t7.schema.targets.aggregate), a("esri-2d-update-debug") && e3.describe(), this._set("config", t7); } async applyUpdate(e3) { e3.version = this._updateVersion, a("esri-2d-update-debug") && console.debug(`Applying update ${e3.version}`), e3.mesh && this.clearTiles(), this._updateQueue.resume(), await this._source.applyUpdate(e3), this.notifyChange("updating"), await j2(() => !this.updating), r(this.aggregateStore) && (await L(10), await j2(() => !this.updating)); } async onEdits({ edits: e3 }) { a("esri-2d-update-debug") && console.debug("Applying Edit:", e3), this._didEdit = true; try { const t7 = e3.removed.map((e4) => e4.objectId && e4.objectId !== -1 ? e4.objectId : this._lookupObjectIdByGlobalId(e4.globalId)), r5 = e3.addOrModified.map(({ objectId: e4 }) => e4); this.featureStore.invalidate(), await this._source.edit(r5, t7), this.clearTiles(), this.notifyChange("updating"), r(this.aggregateStore) && this.aggregateStore.clear(), await this._source.resend(), await j2(() => !this.updating); } catch (t7) { } } async refresh(e3) { if (!e3) { const e4 = t4.empty(); return e4.storage.filters = true, this.applyUpdate(e4); } this.featureStore.invalidate(), this.clearTiles(), this._source.refresh(this._updateVersion), this._cleanupNeeded = true, this.notifyChange("updating"), await j2(() => !this.updating); } clearTiles() { for (const e3 of this.tileStore.tiles) this.processor.onTileClear(e3); } onTileUpdate(e3) { r(this.aggregateStore) && this.aggregateStore.onTileUpdate(e3); for (const t7 of e3.added) this._source.subscribe(t7, this._updateVersion), this._level = t7.level; for (const t7 of e3.removed) this._source.unsubscribe(t7), this._cleanupNeeded = true, this._tileToResolver.has(t7.id) && (this._tileToResolver.get(t7.id).resolve(), this._tileToResolver.delete(t7.id)); this.notifyChange("updating"); } async onIdle() { this._invalidated && (this._invalidated = false, (r(this.aggregateStore) || this.processor.type === "heatmap") && await this._repushCurrentLevelTiles()), this._markAndSweep(); } async querySummaryStatistics({ query: e3, params: t7 }) { return this.queryEngine.executeQueryForSummaryStatistics(e3, t7); } async queryUniqueValues({ query: e3, params: t7 }) { return this.queryEngine.executeQueryForUniqueValues(e3, t7); } async queryClassBreaks({ query: e3, params: t7 }) { return this.queryEngine.executeQueryForClassBreaks(e3, t7); } async queryHistogram({ query: e3, params: t7 }) { return this.queryEngine.executeQueryForHistogram(e3, t7); } queryExtent(e3) { return this.queryEngine.executeQueryForExtent(e3); } queryFeatures(e3) { return this.queryEngine.executeQuery(e3); } async queryVisibleFeatures(e3) { const t7 = await this.queryEngine.executeQuery(e3), r5 = t7.objectIdFieldName; return t7.features = t7.features.filter((e4) => { const t8 = e4.attributes[r5], s8 = this.getDisplayId(t8); return o(s8, (e5) => this.attributeStore.isVisible(e5)); }), t7; } queryFeatureCount(e3) { return this.queryEngine.executeQueryForCount(e3); } queryLatestObservations(e3) { return this.queryEngine.executeQueryForLatestObservations(e3); } queryObjectIds(e3) { return this.queryEngine.executeQueryForIds(e3); } async queryStatistics() { return this.featureStore.storeStatistics; } getObjectId(e3) { return this.featureStore.lookupObjectId(e3, this._storage); } getDisplayId(e3) { if (r(this.aggregateStore)) { const t7 = this.aggregateStore.getDisplayId(e3); if (t(t7)) { const t8 = this.featureStore.lookupDisplayId(e3); return this.aggregateStore.getDisplayIdForReferenceId(t8); } return t7; } return this.featureStore.lookupDisplayId(e3); } getFeatures(e3) { const t7 = [], r5 = []; for (const s8 of e3) { const e4 = r(this.aggregateStore) ? this.getAggregate(s8) : null; if (r(e4)) if (r(e4.referenceId)) { const r6 = this.getFeature(e4.referenceId); r(r6) && t7.push(r6); } else r5.push(e4); else { const e5 = this.getFeature(s8); r(e5) && t7.push(e5); } } return { features: t7, aggregates: r5 }; } getFeature(e3) { const t7 = this.featureStore.lookupFeatureByDisplayId(e3, this._storage); if (t(t7)) return null; const r5 = t7.readHydratedGeometry(), i4 = ne(r5, t7.geometryType, t7.hasZ, t7.hasM); return { attributes: t7.readAttributes(), geometry: i4 }; } getAggregate(e3) { return t(this.aggregateStore) ? null : this.aggregateStore.getAggregate(e3); } getAggregates() { return t(this.aggregateStore) ? [] : this.aggregateStore.getAggregates(); } async setHighlight(e3) { const t7 = g(e3.map((e4) => this.getDisplayId(e4))); return this.attributeStore.setHighlight(e3, t7); } _lookupObjectIdByGlobalId(e3) { const t7 = this.service.globalIdField; if (t(t7)) throw new Error("Expected globalIdField to be defined"); let r5 = null; if (this.featureStore.forEach((s8) => { e3 === s8.readAttribute(t7) && (r5 = s8.getObjectId()); }), t(r5)) throw new Error(`Expected to find a feature with globalId ${e3}`); return r5; } async _repushCurrentLevelTiles() { const e3 = this.tileStore.tiles.filter((e4) => e4.level === this._level).map(async (e4) => this._patchTile({ type: "append", id: e4.key.id, addOrUpdate: d5.fromOptimizedFeatures([], this.service), remove: [], end: true, status: t4.empty() })); await Promise.all(e3); } _maybeForceCleanup() { performance.now() - this._lastCleanup > T && this._markAndSweep(); } _patchTile(e3, t7) { const r5 = this._updateQueue.push(e3, t7).then(() => { this.notifyChange("updating"); }).catch((e4) => { this.notifyChange("updating"); }); return this.notifyChange("updating"), r5; } async _onTileMessage(e3, t7) { f2(t7); const r5 = this.tileStore.get(e3.id); if (!r5) return; if (e3.clear) return this.processor.onTileClear(r5); const i4 = e3.status; this._cleanupNeeded = true; const o11 = []; for (const s8 of e3.remove) { const e4 = this.featureStore.lookupDisplayId(s8); e4 && o11.push(e4); } e3.remove = o11; try { if (t(e3.addOrUpdate)) return void this.processor.onTileMessage(r5, { ...e3, addOrUpdate: null }, r(this.aggregateStore), t7).catch(b); if (e3.addOrUpdate.setArcadeSpatialReference(this.spatialReference), this.featureStore.hasInstance(e3.addOrUpdate.instance) && i4.targets.feature || (i4.targets.feature = true, this.featureStore.onTileData(r5, e3)), !i4.storage.data || !i4.storage.filters) { i4.storage.data = true, i4.storage.filters = true, this.attributeStore.onTileData(r5, e3); this._source.type === "geoevent" || this._didEdit ? (await this.attributeStore.sendUpdates(), f2(t7)) : this.attributeStore.sendUpdates(); } if (r(this.aggregateStore) && !i4.targets.aggregate) { i4.targets.aggregate = true; const t8 = Q2(this._source) && this._source.loading, s8 = !Q2(this._source) || t8 || e3.end; if (this.aggregateStore.onTileData(r5, e3, this._storage, this.attributeStore, s8), !s8) return; i4.mesh || (this.attributeStore.onTileData(r5, e3), await this.attributeStore.sendUpdates()); } i4.mesh || (i4.mesh = true, await this.processor.onTileMessage(r5, e3, r(this.aggregateStore), t7), f2(t7)), this._maybeForceCleanup(); } catch (n6) { b(n6); } } _mark(e3, t7, r5) { const s8 = (4294901760 & this._storage.getInstanceId(e3)) >>> 16; e3 && (t7.add(s8), r5.set(e3)); } _markAndSweep() { this._lastCleanup = performance.now(); if (!(!(this._source.type === "feature" && this._source.mode === "snapshot") && (this._source.type === "geoevent" || this._cleanupNeeded))) return; this._cleanupNeeded = false; const e3 = this._storage.getBitset(this._markedIdsBufId), t7 = new Set(); e3.clear(); for (const r5 of this.tileStore.tiles) for (const s8 of this._source.readers(r5.id)) { const r6 = s8.getCursor(); for (; r6.next(); ) { let s9 = r6.getDisplayId(); if (!s9) { const e4 = r6.getObjectId(); s9 = this.featureStore.lookupDisplayId(e4); } this._mark(s9, t7, e3); } } this.processor.type === "symbol" && this.processor.forEachBufferId((r5) => { this._mark(r5, t7, e3); }), this._updateQueue.forEach((r5) => { for (const s8 of r5.remove) { const r6 = this.featureStore.lookupDisplayId(s8); this._mark(r6, t7, e3); } }), r(this.aggregateStore) && (this.aggregateStore.sweepFeatures(e3, this.featureStore), "sweepAggregates" in this.aggregateStore && this.aggregateStore.sweepAggregates(this._storage, this.attributeStore, this._level)), this.featureStore.sweepFeatures(e3, this._storage, this.attributeStore), this.featureStore.sweepFeatureSets(t7); } }; e([d({ constructOnly: true })], O.prototype, "tileStore", void 0), e([d()], O.prototype, "config", void 0), e([d({ readOnly: true })], O.prototype, "fieldsIndex", null), e([d()], O.prototype, "processor", void 0), e([d({ constructOnly: true })], O.prototype, "remoteClient", void 0), e([d({ constructOnly: true })], O.prototype, "service", void 0), e([d()], O.prototype, "spatialReference", null), e([d()], O.prototype, "updating", null), O = e([n("esri.views.2d.layers.features.controllers.FeatureController2D")], O); var A3 = O; // node_modules/@arcgis/core/views/2d/layers/features/Pipeline.js var d10 = class extends d4 { constructor() { super(...arguments), this.controller = null, this.processor = null, this.remoteClient = null, this.tileStore = null, this.service = null, this.viewState = null, this._paused = false, this._pendingTileUpdates = []; } initialize() { this.handles.add(l(() => this.updating, (e3) => { this.remoteClient.invoke("setUpdating", e3).catch((e4) => { }); })); } destroy() { this.stop(), this.controller?.destroy(), this.processor?.destroy(), this.controller = this.processor = this.tileStore = this.remoteClient = null; } get updating() { return !this.controller || this.controller.updating; } stop() { this._paused = true, Array.isArray(this.service?.source) && (this.service.source.forEach((e3) => e3.close()), this.service.source.length = 0), this.tileStore?.updateTiles({ added: [], removed: this.tileStore.tiles.map((e3) => e3.id) }), this.tileStore?.destroy(), this.tileStore = null, this._pendingTileUpdates.length = 0; } async startup({ service: e3, config: t7, tileInfo: r5, tiles: s8 }) { if (this._paused = true, Array.isArray(this.service?.source) && (this.service.source.forEach((e4) => e4.close()), this.service.source.length = 0), this.service = e3, !this.tileStore || !E3(this.tileStore.tileScheme.spatialReference, r5.spatialReference)) { const e4 = new h(S.fromJSON(r5)); s8.added.length = s8.removed.length = 0, this.tileStore?.updateTiles({ added: [], removed: this.tileStore.tiles.map((e5) => e5.id) }), this.tileStore?.destroy(), this.tileStore = new l4(e4), this._pendingTileUpdates.length = 0; } for (await this._createProcessorAndController(t7), await this.update({ config: t7 }), this.controller.resume(), this.tileStore.clear(), this.tileStore.updateTiles(s8), this._paused = false; this._pendingTileUpdates.length; ) this.tileStore.updateTiles(this._pendingTileUpdates.pop()); } async updateTiles(e3) { this._paused ? this._pendingTileUpdates.push(e3) : this.tileStore.updateTiles(e3); } async update({ config: e3 }) { const t7 = t4.empty(); return await Promise.all([this.processor.update(t7, e3), this.controller.update(t7, e3)]), t7.toJSON(); } async applyUpdate(e3) { return this.controller.applyUpdate(t4.create(e3)); } async _createProcessorAndController(e3) { await Promise.all([this._handleControllerConfig(e3), this._handleProcessorConfig(e3)]), this.controller.processor = this.processor; } async _handleControllerConfig(e3) { return this._createController(this.service, e3); } async _handleProcessorConfig(e3) { return this._createProcessor(this.service, e3); } async _createController(e3, t7) { this.controller && this.controller.destroy(); const { tileStore: r5, remoteClient: s8 } = this, o11 = new A3({ service: e3, tileStore: r5, remoteClient: s8 }); return this.controller = o11, o11; } async _createProcessor(e3, t7) { const r5 = t7.schema.processors[0].type, s8 = (await o6(r5)).default, { remoteClient: o11, tileStore: i4 } = this, l9 = new s8({ service: e3, config: t7, tileStore: i4, remoteClient: o11 }); return this.processor && this.processor.destroy(), this.processor = l9, l9; } }; e([d()], d10.prototype, "controller", void 0), e([d()], d10.prototype, "processor", void 0), e([d()], d10.prototype, "updating", null), e([d()], d10.prototype, "viewState", void 0), d10 = e([n("esri.views.2d.layers.features.Pipeline")], d10); var u4 = d10; export { u4 as default }; //# sourceMappingURL=Pipeline-FIWUDD7H.js.map