BaseGraphicContainer.8f76c915.js 57 KB

123456789101112
  1. import{a as F,ap as E,aq as b,ar as Ke,k as Ee,as as fe,at as qe,au as de,t as A,av as He,aw as ne,ax as Ne,ay as Ze,az as Ye,aA as Qe,aB as Ge,aC as We,aD as Oe,aE as Xe,aF as Je,aG as et,A as N,aH as tt,_ as v,$ as C,a0 as $e,h as st,Y as it,aI as rt,R as nt,l as x,aJ as ot,aK as at,m as Z,aL as lt,aM as _e,aN as xe,aO as ve,aP as ht,aQ as be,aR as oe,aS as dt,aT as ct,aU as ut,a1 as ft,F as De,aV as pt,aW as mt,M as gt,aX as yt,I as _t,J as xt}from"./index.6c049565.js";import{d as Ce,V as vt,Q as bt,n as Dt}from"./ExpandedCIM.64535143.js";import{p as Ct}from"./normalizeUtilsSync.f896b328.js";import{f as Bt,g as wt}from"./projectionSupport.2b4a8796.js";import{U as Tt}from"./enums.0295eb81.js";import{K as pe,X,c as ce,i as Ft,s as Rt,W as ee,G as It,h as St,S as Ue,g as Mt}from"./Utils.e8554a0e.js";import{a as Pe,E as te}from"./VertexArrayObject.729879be.js";import{F as ue,R as Be,E as Lt,C as Ve,I as At}from"./enums.2d9e6f64.js";import{m as zt,i as Gt,o as Ot}from"./FeatureContainer.8e5dd053.js";import{U as $t}from"./MaterialKey.bbaab8f1.js";import{a as J,l as Ut,x as Pt,b as Vt,n as kt,E as jt}from"./Matcher.d9c9cebd.js";import{w as we,$ as Kt}from"./schemaUtils.7eee5b9f.js";import{c as Et,b as qt,r as Ht,v as Nt}from"./ComputedAttributeStorage.dc79b701.js";import{O as Zt,U as P}from"./quantizationUtils.4f3ed95a.js";import{createSymbolSchema as Yt}from"./createSymbolSchema.30665f63.js";import{r as Qt}from"./vec3f32.1121a836.js";import{r as Wt}from"./utils.eb2c3fd5.js";const g=-1;class Te{constructor(){this._dirties=[{vertexFrom:g,vertexCount:g,indexFrom:g,indexCount:g,allDirty:!1},{vertexFrom:g,vertexCount:g,indexFrom:g,indexCount:g,allDirty:!1},{vertexFrom:g,vertexCount:g,indexFrom:g,indexCount:g,allDirty:!1},{vertexFrom:g,vertexCount:g,indexFrom:g,indexCount:g,allDirty:!1},{vertexFrom:g,vertexCount:g,indexFrom:g,indexCount:g,allDirty:!1}]}hasDirty(){return this._dirties.some(e=>e.indexCount!==g||e.allDirty)}markAllClean(){for(const e of this._dirties)e.indexFrom=g,e.indexCount=g,e.vertexFrom=g,e.vertexCount=g,e.allDirty=!1}markAllDirty(){for(const e of this._dirties)e.allDirty=!0}forEach(e){for(let t=0;t<this._dirties.length;++t){const{indexCount:s,indexFrom:i,vertexCount:r,vertexFrom:n,allDirty:a}=this._dirties[t],l={};let d,h=!1;(a||n!==g&&r>0)&&(l.geometry={count:r,from:n,allDirty:a},h=!0),(a||i!==g&&s>0)&&(d={count:s,from:i,allDirty:a},h=!0),h&&e({indices:d,vertices:l},t)}}markDirtyIndices(e,t,s){const i=this._dirties[e],r=t,n=s;if(!i.allDirty)if(i.indexCount!==g){const a=Math.min(i.indexFrom,r),l=Math.max(i.indexFrom+i.indexCount,r+n)-a;i.indexFrom=a,i.indexCount=l}else i.indexFrom=r,i.indexCount=n}markDirtyVertices(e,t,s,i){const r=this._dirties[e],n=s,a=i;if(!r.allDirty)if(r.vertexCount!==g){const l=Math.min(r.vertexFrom,n),d=Math.max(r.vertexFrom+r.vertexCount,n+a)-l;r.vertexFrom=l,r.vertexCount=d}else r.vertexFrom=n,r.vertexCount=a}}class Xt{constructor(e){this._largestRange=null,this._parent=e,this._updateLargestRange()}get largestRange(){return this._largestRange}rangeCreated(e){(!this._largestRange||e.count>this._largestRange.count)&&(this._largestRange=e)}rangeResized(e,t){e===this._largestRange?e.count<t&&this._updateLargestRange():(!this._largestRange||e.count>this._largestRange.count)&&(this._largestRange=e)}findBestRange(e){let t=this._parent._freeHead,s=null;for(;t!==null;)t.count>=e&&(!s||t.count-e<s.count-e)&&(s=t),t=t.next;return s}findAdjacentRanges(e,t){let s=!0,i=!1,r=null,n=this._parent._freeHead;for(;s&&!i;){const a=r!==null?r.from+r.count:0,l=n!==null?n.from:this._parent._size;e>=a&&e+t<=l?(s=!1,i=!0):n!==null?(r=n,n=n.next):s=!1}return[r,n]}_updateLargestRange(){let e=null,t=this._parent._freeHead;for(;t!==null;)(!e||t.count>e.count)&&(e=t),t=t.next;this._largestRange=e}}class B{constructor(e,t){this._allocated=0,this._size=e,this._freeHead=e>0?{from:0,count:e,prev:null,next:null}:null,this._bookKeeper=t||new Xt(this),this._freeHead&&this._bookKeeper.rangeCreated(this._freeHead)}allocate(e){const t=this._bookKeeper.findBestRange(e);if(t===null)return-1;const s=t.from,i=t.count;if(t.from+=e,t.count-=e,this._bookKeeper.rangeResized(t,s,i),this._allocated+=e,t.count===0){const r=t.prev!==null?this._freeHead:t.next;B._removeRange(t),this._freeHead=r}return s}free(e,t){const[s,i]=this._bookKeeper.findAdjacentRanges(e,t),r={from:e,count:t,prev:s,next:i};if(s!==null&&(s.next=r),i!==null&&(i.prev=r),this._bookKeeper.rangeCreated(r),this._allocated-=t,i!==null&&r.from+r.count===i.from){const n=r.from,a=r.count;B._fuse(r,i),B._removeRange(i),this._bookKeeper.rangeResized(r,n,a),this._bookKeeper.rangeResized(i,void 0,0)}if(s!==null&&s.from+s.count===r.from){const n=s.from,a=s.count;B._fuse(s,r),B._removeRange(r),this._bookKeeper.rangeResized(s,n,a),this._bookKeeper.rangeResized(r,void 0,0)}this._freeHead=r.prev!==null?this._freeHead:r}get fragmentation(){const e=this._size-this._allocated;return e===0?0:1-this._bookKeeper.largestRange.count/e}static _removeRange(e){e.prev!==null?e.next!==null?(e.prev.next=e.next,e.next.prev=e.prev):e.prev.next=null:e.next!==null&&(e.next.prev=null)}static _fuse(e,t){e.count+=t.count,e.next=t.next,t.from+=t.count,t.count=0,t.next!==null&&(t.next.prev=e)}}const j=["FILL","LINE","MARKER","TEXT","LABEL"];function Jt(o){const e=o.getStrides(),t={};for(let s=0;s<e.length;s++)t[j[s]]=e[s];return t}const Fe=.5;class se{constructor(e,t,s,i){this._strides=e,this._displayList=t,this._freeListsAndStorage={},this._dirtyMap=null,this._dirtyMap=s;for(const r in e){this._freeListsAndStorage[r]={vtxFreeList:i?new B(i):null,idxFreeList:i?new B(i):null,vertexBuffers:{},indexBuffer:i?new Uint32Array(i):null};for(const n in e[r])this._freeListsAndStorage[r].vertexBuffers[n]={data:i?pe(i,e[r][n]):null,stride:e[r][n]}}}static fromTileData(e,t){const s=Jt(e),i=[0,0,0,0,0],r=[0,0,0,0,0],n=e.tileDisplayData.displayObjects;for(const l of n)for(const d of l.displayRecords)i[d.geometryType]=Math.max(i[d.geometryType],d.vertexFrom+d.vertexCount),r[d.geometryType]=Math.max(r[d.geometryType],d.indexFrom+d.indexCount);const a=new se(s,e.tileDisplayData.displayList,t,null);for(let l=0;l<e.tileBufferData.geometries.length;++l){const d=i[l],h=r[l],c=e.tileBufferData.geometries[l],u=j[l],p=a._storageFor(u),f=e.tileBufferData.geometries[l].indexBuffer;let m;p.indexBuffer=f,p.idxFreeList=new B(f.length),p.idxFreeList.allocate(h);for(const _ in c.vertexBuffer){const y=e.tileBufferData.geometries[l].vertexBuffer[_];p.vertexBuffers[_].data=y.data,p.vertexBuffers[_].stride=y.stride;const I=X(y.stride),H=y.data.length*I/y.stride;m||(m=H)}p.vtxFreeList=new B(m),p.vtxFreeList.allocate(d)}return a}delete(e){const t=j[e.geometryType];this._freeVertices(t,e.vertexFrom,e.vertexCount),this._freeIndices(t,e.indexFrom,e.indexCount),this._displayList.removeFromList(e),e.vertexFrom=void 0,e.indexFrom=void 0}setMeshData(e,t,s,i,r){const n=j[e.geometryType];let a,l;e.meshData=null,e.vertexFrom===void 0?(l=t.vertexCount,a=this._allocateVertices(n,l)):t.vertexCount>e.vertexCount?(this._freeVertices(n,e.vertexFrom,e.vertexCount),l=t.vertexCount,a=this._allocateVertices(n,l)):t.vertexCount===e.vertexCount?(a=e.vertexFrom,l=e.vertexCount):(this._freeVertices(n,e.vertexFrom+t.vertexCount,e.vertexCount-t.vertexCount),a=e.vertexFrom,l=t.vertexCount);let d,h,c,u=!0;if(e.indexFrom===void 0?(d=r,c=t.indexCount,h=this._allocateIndices(n,c)):t.indexCount>e.indexCount?(d=this._displayList.removeFromList(e),this._freeIndices(n,e.indexFrom,e.indexCount),c=t.indexCount,h=this._allocateIndices(n,c)):t.indexCount===e.indexCount?(u=!1,h=e.indexFrom,c=e.indexCount):(d=this._displayList.removeFromList(e),this._freeIndices(n,e.indexFrom+t.indexCount,e.indexCount-t.indexCount),h=e.indexFrom,c=t.indexCount),a!==-1&&h!==-1){const p=this._storageFor(n);if(ce(a,h,p.vertexBuffers,p.indexBuffer,t,s,i),e.vertexFrom=a,e.indexFrom=h,e.vertexCount=t.vertexCount,e.indexCount=t.indexCount,this._dirtyMap){this._dirtyMap.markDirtyIndices(e.geometryType,e.indexFrom,e.indexCount);for(const f in s)this._dirtyMap.markDirtyVertices(e.geometryType,f,e.vertexFrom,e.vertexCount)}return u&&this._displayList.addToList(e,d),!0}return a!==-1&&this._freeVertices(n,a,l),h!==-1&&this._freeIndices(n,h,c),e.setMeshDataFromBuffers(t,s,i),e.vertexFrom=void 0,e.vertexCount=0,e.indexFrom=void 0,e.indexCount=0,!1}tryAddMeshData(e,t){const s=t.vertexBuffer,i=t.indexBuffer,r=j[e.geometryType],n=this._allocateVertices(r,e.vertexCount);if(n===-1)return this._freeVertices(r,n,e.vertexCount),!1;const a=this._allocateIndices(r,e.indexCount);if(a===-1)return this._freeVertices(r,n,e.vertexCount),this._freeIndices(r,a,e.indexCount),!1;const l=this._storageFor(r);if(ce(n,a,l.vertexBuffers,l.indexBuffer,e,s,i),e.vertexFrom=n,e.indexFrom=a,this._dirtyMap){this._dirtyMap.markDirtyIndices(e.geometryType,e.indexFrom,e.indexCount);for(const d in s)this._dirtyMap.markDirtyVertices(e.geometryType,d,n,e.vertexCount)}return this._displayList.addToList(e),!0}_allocateVertices(e,t){const s=this._storageFor(e),i=s.vtxFreeList.allocate(t);return i===-1||s.vtxFreeList.fragmentation>Fe?-1:i}_freeVertices(e,t,s){this._storageFor(e).vtxFreeList.free(t,s)}_freeIndices(e,t,s){this._storageFor(e).idxFreeList.free(t,s)}_allocateIndices(e,t){const s=this._storageFor(e),i=s.idxFreeList.allocate(t);return i===-1||s.idxFreeList.fragmentation>Fe?-1:i}_storageFor(e){return this._freeListsAndStorage[e]}_stridesFor(e,t){return this._strides[e][t]}}class es{constructor(e){this.geometryMap=Ft(()=>({indexBuffer:te.createIndex(e,ue.STATIC_DRAW),vao:null}),(t,s)=>({vertexBuffer:te.createVertex(e,Rt[s])}))}dispose(){for(let e=0;e<5;e++){const t=this.geometryMap[e];if(t){t.data.vao&&t.data.vao.dispose(!1),t.data.indexBuffer&&t.data.indexBuffer.dispose();for(const s in t.buffers)t.buffers[s]&&t.buffers[s].data.vertexBuffer.dispose()}}}get(e){const t=this.geometryMap[e];return{getVAO(s,i,r){if(!t.data.vao){const n={};for(const a in t.buffers)n[a]=t.buffers[a].data.vertexBuffer;t.data.vao=new Pe(s,r,i,n,t.data.indexBuffer)}return t.data.vao}}}has(e){return this.geometryMap[e]!=null}upload(e,t){t.forEach((s,i)=>{this._upload(s,i,e)})}_upload(e,t,s){if(e.indices&&(e.indices.allDirty?this._uploadIndices(s,t):e.indices.from!=null&&e.indices.count!=null&&this._uploadIndices(s,t,e.indices.from,e.indices.count)),e.vertices){const i=e.vertices;for(const r in i){const n=i[r];n.allDirty?this._uploadVertices(s,t,r):n.from!=null&&n.count!=null&&this._uploadVertices(s,t,r,n.from,n.count)}}}_uploadVertices(e,t,s,i,r){const n=this.geometryMap[t];if(!n)return;const a=e.geometries[t].vertexBuffer[s];if(!a)return;const{data:l,stride:d}=a;if(n.buffers[s]&&l.length>0){const h=d/l.BYTES_PER_ELEMENT;i!=null&&r!=null?n.buffers[s].data.vertexBuffer.setSubData(l,i*h,i*h,(i+r)*h):n.buffers[s].data.vertexBuffer.setData(l)}}_uploadIndices(e,t,s,i){const r=this.geometryMap[t];if(!r)return;const n=e.geometries[t].indexBuffer;r.data.indexBuffer&&n.length>0&&(s!=null&&i!=null?r.data.indexBuffer.setSubData(n,s,s,s+i):r.data.indexBuffer.setData(n))}}class ts extends zt{constructor(){super(...arguments),this._data=null,this._displayList=null,this._lastCommitTime=0,this._hasData=!1,this._invalidated=!1,this._wglBuffers=null,this._dirtyMap=new Te}destroy(){super.destroy(),this.clear()}get hasData(){return!!this._hasData}get displayObjects(){var e;return(e=this._displayObjects)!=null?e:[]}getGeometry(e){return this._wglBuffers&&this._wglBuffers.has(e)?this._wglBuffers.get(e):null}getDisplayList(){return this._displayList}patch(e){if(e.clear===!0)return this.clear(),void(this._hasData=!1);const t=e.addOrUpdate,s=e.remove;!this._data&&t&&t.tileDisplayData.displayObjects.length?(t.tileDisplayData.computeDisplayList(),this._dirtyMap=new Te,this._dispRecStore=se.fromTileData(t,this._dirtyMap),this._data=t,this._dirtyMap.markAllDirty(),this._hasData=!0,e.end&&this.ready()):this._data&&(t&&t.tileDisplayData.displayObjects.length||s.length)?this._doPatchData(e):e.end&&this.ready(),e.end&&!this._data&&this.clear(),this.requestRender(),this.emit("change")}commit(e){e.time&&e.time===this._lastCommitTime||(this._lastCommitTime=e.time,this.visible&&this._data&&(this._wglBuffers||(this._wglBuffers=new es(e.context)),(this._dirtyMap.hasDirty()||this._invalidated)&&(this._invalidated=!1,this._wglBuffers.upload(this._data.tileBufferData,this._dirtyMap),this._displayList=this._data.tileDisplayData.displayList.clone(),this._displayObjects=this._data.tileDisplayData.displayObjects.slice(),this._dirtyMap.markAllClean())))}clear(){this._data=null,this._displayList=null,this._dispRecStore=null,this._wglBuffers&&(this._wglBuffers.dispose(),this._wglBuffers=null)}_doPatchData(e){this._invalidated=!0,this._patchData(e)||(this._dirtyMap.markAllDirty(),this._data.reshuffle(),this._dispRecStore=se.fromTileData(this._data,this._dirtyMap)),this.requestRender()}_patchData(e){let t=!0;const s=e.addOrUpdate&&e.addOrUpdate.tileDisplayData&&e.addOrUpdate.tileDisplayData.displayObjects||[],i=(e.remove||[]).slice();for(const n of s)n.insertAfter!=null&&i.push(n.id);let r;i.length>0&&(r=new Set(i));for(const n of i){const a=this._data.tileDisplayData.displayObjectRegistry.get(n);if(a){this._data.tileDisplayData.displayList.removeFromList(a.displayRecords);for(const l of a.displayRecords)this._dispRecStore.delete(l);this._data.tileDisplayData.displayObjectRegistry.delete(n)}}r&&r.size&&(this._data.tileDisplayData.displayObjects=this._data.tileDisplayData.displayObjects.filter(n=>!r.has(n.id)));for(const n of s){let a,l=this._data.tileDisplayData.displayObjectRegistry.get(n.id);if(l){const h=l.displayRecords;l.set(n),l.displayRecords=h;const c=l.displayRecords.length;for(let u=0;u<c;++u){const p=l.displayRecords[u],f=n.displayRecords[u];(u>=n.displayRecords.length||p.geometryType!==f.geometryType||p.symbolLevel!==f.symbolLevel||p.zOrder!==f.zOrder||p.materialKey!==f.materialKey)&&(this._dispRecStore.delete(l.displayRecords[u]),u<n.displayRecords.length&&(l.displayRecords[u]=void 0))}l.displayRecords.length=n.displayRecords.length}else{let h;l=n.copy(),l.displayRecords=[],this._data.tileDisplayData.displayObjectRegistry.set(n.id,l);const c=this._data.tileDisplayData.displayObjects;if(l.insertAfter!=null)if(a={},l.insertAfter>=0){const u=this._data.tileDisplayData.displayObjectRegistry.get(l.insertAfter);u?(h=c.indexOf(u)+1,h<c.length?c.splice(h,0,l):(c.push(l),h=c.length)):(c.push(l),h=c.length)}else c.unshift(l),h=0;else c.push(l),h=c.length;if(a){const u=n.displayRecords.length>0?1:0;let p=0;for(let f=h-1;f>=0&&p<u;--f)for(let m=c[f].displayRecords.length-1;m>=0&&p<u;--m){const _=c[f].displayRecords[m],y=this._data.tileDisplayData.displayList.getDPInfoType();a[y]||(a[y]=_,++p)}}}const d=n.displayRecords.length;for(let h=0;h<d;++h){const c=n.displayRecords[h];let u=l.displayRecords[h];u?(u.meshData=c.meshData,u.materialKey=c.materialKey):(u=c.copy(),u.vertexFrom=void 0,u.indexFrom=void 0,l.displayRecords[h]=u);const p=c.geometryType,f=this._data.tileDisplayData.displayList.getDPInfoType(),m=e.addOrUpdate.tileBufferData.geometries[p],_=m.vertexBuffer,y=m.indexBuffer;let I;a&&(I=a[f]?this._data.tileDisplayData.displayList.splitAfter(a[f]):-1),t=this._dispRecStore.setMeshData(u,c,_,y,I)&&t,a&&u.indexFrom!=null&&u.indexFrom!=null&&(a[f]=u)}}return t}}class ke{constructor(){this._byGeometryType=null}get satisfied(){return!this._byGeometryType}reset(){this._byGeometryType=null}verticesFor(e){return this._byGeometryType?this._byGeometryType[e].vertices:0}indicesFor(e){return this._byGeometryType?this._byGeometryType[e].indices:0}needMore(e,t,s){if(!t&&!s)return;this._byGeometryType||(this._byGeometryType=[{vertices:0,indices:0},{vertices:0,indices:0},{vertices:0,indices:0},{vertices:0,indices:0},{vertices:0,indices:0}]);const i=this._byGeometryType[e];i.vertices+=t,i.indices+=s}}const ae=5;class z{constructor(){this.geometries=[{indexBuffer:void 0,vertexBuffer:{}},{indexBuffer:void 0,vertexBuffer:{}},{indexBuffer:void 0,vertexBuffer:{}},{indexBuffer:void 0,vertexBuffer:{}},{indexBuffer:void 0,vertexBuffer:{}}]}clone(){const e=new z;for(let t=0;t<this.geometries.length;t++){const s=this.geometries[t],i=e.geometries[t];i.indexBuffer=s.indexBuffer.slice(),i.vertexBuffer={};for(const r in s.vertexBuffer){const{data:n,stride:a}=s.vertexBuffer[r];i.vertexBuffer[r]={data:n.slice(),stride:a}}}return e}static deserialize(e){const t=new z;for(let s=0;s<ae;++s){t.geometries[s].indexBuffer=new Uint32Array(e.geometries[s].indexBuffer),t.geometries[s].vertexBuffer={};for(const i in e.geometries[s].vertexBuffer)t.geometries[s].vertexBuffer[i]={data:ee(e.geometries[s].vertexBuffer[i].data,e.geometries[s].vertexBuffer[i].stride),stride:e.geometries[s].vertexBuffer[i].stride}}return t}serialize(){const e={geometries:[{indexBuffer:this.geometries[0].indexBuffer.buffer,vertexBuffer:{}},{indexBuffer:this.geometries[1].indexBuffer.buffer,vertexBuffer:{}},{indexBuffer:this.geometries[2].indexBuffer.buffer,vertexBuffer:{}},{indexBuffer:this.geometries[3].indexBuffer.buffer,vertexBuffer:{}},{indexBuffer:this.geometries[4].indexBuffer.buffer,vertexBuffer:{}}]};for(let t=0;t<ae;++t)for(const s in this.geometries[t].vertexBuffer)e.geometries[t].vertexBuffer[s]={data:this.geometries[t].vertexBuffer[s].data.buffer,stride:this.geometries[t].vertexBuffer[s].stride};return e}getBuffers(){const e=[];for(let t=0;t<ae;++t){e.push(this.geometries[t].indexBuffer.buffer);for(const s in this.geometries[t].vertexBuffer)e.push(this.geometries[t].vertexBuffer[s].data.buffer)}return e}}function Y(o,e,t,...s){e<o.length?o.splice(e,t,...s):o.push(...s)}class me{constructor(){this.symbolLevels=[]}replay(e,t,s){for(const i of this.symbolLevels)for(const r of i.zLevels){const n=r.geometryDPInfo.unified;if(n)for(const a of n){const{geometryType:l,materialKey:d,indexFrom:h,indexCount:c}=a,u=$t.load(d).symbologyType,p=e.painter.getBrush(l,u),f={geometryType:l,materialKey:d,indexFrom:h,indexCount:c,target:t.getGeometry(l)};p.prepareState(e),p.drawGeometry(e,t,f,s)}}}get empty(){return!this.symbolLevels||this.symbolLevels.length===0}clear(){this.symbolLevels.length=0}addToList(e,t){if(Array.isArray(e))for(const s of e)this._addToList(s,t);else this._addToList(e,t)}removeFromList(e){Array.isArray(e)||(e=[e]);let t=null;for(const s of e)t=this._removeFromList(s);return t}clone(){const e=new me;for(const t of this.symbolLevels)e.symbolLevels.push(t.clone());return e}splitAfter(e){const t=this._getDisplayList(e.symbolLevel,e.zOrder),s=t.length,i=e.indexFrom+e.indexCount;for(let r=0;r<s;++r){const n=t[r];if(n.geometryType===e.geometryType&&i>n.indexFrom&&i<=n.indexFrom+n.indexCount){if(i<n.indexFrom+n.indexCount){const a=new K;a.geometryType=n.geometryType,a.materialKey=n.materialKey,a.indexFrom=i,a.indexCount=n.indexFrom+n.indexCount-i,t.splice(r+1,0,a),n.indexCount=i-n.indexFrom}return r}}}_addToList(e,t){const s=e.symbolLevel,i=e.zOrder,r=this._getDisplayList(s,i),n=t!=null?t:r.length-1,a=n>=0&&n<r.length?r[n]:null;if(a!==null&&a.materialKey===e.materialKey&&a.indexFrom+a.indexCount===e.indexFrom&&a.geometryType===e.geometryType)a.indexCount+=e.indexCount;else{const l=new K;l.indexFrom=e.indexFrom,l.indexCount=e.indexCount,l.materialKey=e.materialKey,l.geometryType=e.geometryType,Y(r,n+1,0,l)}}_removeFromList(e){const t=e.symbolLevel,s=e.zOrder,i=this._getDisplayList(t,s),r=i.length;let n;for(let a=0;a<r;++a){const l=i[a];if(e.indexFrom+e.indexCount>l.indexFrom&&e.indexFrom<l.indexFrom+l.indexCount&&l.geometryType===e.geometryType){n=a;break}}if(n!==void 0){const a=i[n];if(e.indexFrom===a.indexFrom)return a.indexCount-=e.indexCount,a.indexFrom+=e.indexCount,a.indexCount===0&&Y(i,n,1),n-1;if(e.indexFrom+e.indexCount===a.indexFrom+a.indexCount)return a.indexCount-=e.indexCount,a.indexCount===0?(Y(i,n,1),n-1):n;{const l=a.indexFrom,d=e.indexFrom-a.indexFrom,h=e.indexCount,c=a.indexFrom+a.indexCount-(e.indexFrom+e.indexCount);a.indexCount=d;const u=new K;return u.geometryType=a.geometryType,u.materialKey=a.materialKey,u.indexFrom=l+d+h,u.indexCount=c,Y(i,n+1,0,u),n}}return null}_getDisplayList(e,t){let s;const i=this.symbolLevels.length;for(let a=0;a<i;a++)if(this.symbolLevels[a].symbolLevel===e){s=this.symbolLevels[a];break}let r;s||(s=new ye,s.symbolLevel=e,this.symbolLevels.push(s));const n=s.zLevels.length;for(let a=0;a<n;a++)if(s.zLevels[a].zLevel===t){r=s.zLevels[a];break}return r||(r=new ge,r.geometryDPInfo=new re,r.zLevel=t,s.zLevels.push(r)),r.geometryDPInfo.unified||(r.geometryDPInfo.unified=[]),r.geometryDPInfo.unified}getDPInfoType(){return"unified"}}class K{constructor(){this.materialKey=null,this.indexFrom=0,this.indexCount=0}clone(){const e=new K;return e.geometryType=this.geometryType,e.materialKey=this.materialKey,e.indexFrom=this.indexFrom,e.indexCount=this.indexCount,e}}class re{constructor(){this.fill=null,this.line=null,this.marker=null,this.text=null,this.label=null,this.unified=null}clone(){const e=new re;return e.fill=this.fill&&this.fill.map(t=>t.clone()),e.line=this.line&&this.line.map(t=>t.clone()),e.marker=this.marker&&this.marker.map(t=>t.clone()),e.text=this.text&&this.text.map(t=>t.clone()),e.label=this.label&&this.label.map(t=>t.clone()),e.unified=this.unified&&this.unified.map(t=>t.clone()),e}}class ge{constructor(){this.geometryDPInfo=new re}clone(){const e=new ge;return e.zLevel=this.zLevel,e.geometryDPInfo=this.geometryDPInfo.clone(),e}}class ye{constructor(){this.zLevels=[]}clone(){const e=new ye;e.symbolLevel=this.symbolLevel;for(const t of this.zLevels)e.zLevels.push(t.clone());return e}}class Re{constructor(){this.vertexData=new Map,this.vertexCount=0,this.indexData=[]}clear(){this.vertexData.clear(),this.vertexCount=0,this.indexData=[]}update(e,t,s){for(const i in e)this.vertexData.set(i,e[i]);for(const i in this.vertexData)e[i]===null&&this.vertexData.delete(i);this.vertexCount=t,this.indexData=s}}class U{constructor(e,t,s,i=0,r=0){this.id=e,this.geometryType=t,this.materialKey=s,this.minZoom=i,this.maxZoom=r,this.meshData=null,this.symbolLevel=0,this.zOrder=0,this.vertexFrom=0,this.vertexCount=0,this.indexFrom=0,this.indexCount=0}get sortKey(){return this._sortKey===void 0&&this._computeSortKey(),this._sortKey}clone(){return this.copy()}copy(){const e=new U(this.id,this.geometryType,this.materialKey);return e.vertexFrom=this.vertexFrom,e.vertexCount=this.vertexCount,e.indexFrom=this.indexFrom,e.indexCount=this.indexCount,e.zOrder=this.zOrder,e.symbolLevel=this.symbolLevel,e.meshData=this.meshData,e.minZoom=this.minZoom,e.maxZoom=this.maxZoom,e}setMeshDataFromBuffers(e,t,s){const i=new Re;for(const r in t){const n=t[r].stride,a=t[r].data,l=[],d=X(n);for(let h=0;h<n*e.vertexCount/d;++h)l[h]=a[h+n*e.vertexFrom/d];i.vertexData.set(r,l)}i.indexData.length=0;for(let r=0;r<e.indexCount;++r)i.indexData[r]=s[r+e.indexFrom]-e.vertexFrom;i.vertexCount=e.vertexCount,this.meshData=i}readMeshDataFromBuffers(e,t){this.meshData?this.meshData.clear():this.meshData=new Re;for(const s in e){const i=e[s].stride,r=e[s].data,n=[],a=X(i);for(let l=0;l<i*this.vertexCount/a;++l)n[l]=r[l+i*this.vertexFrom/a];this.meshData.vertexData.set(s,n)}this.meshData.indexData.length=0;for(let s=0;s<this.indexCount;++s)this.meshData.indexData[s]=t[s+this.indexFrom]-this.vertexFrom;this.meshData.vertexCount=this.vertexCount}writeMeshDataToBuffers(e,t,s,i){for(const r in t){const n=t[r].stride,a=this.meshData.vertexData.get(r),l=t[r].data,d=X(n);for(let h=0;h<n*this.meshData.vertexCount/d;++h)l[h+n*e/d]=a[h]}for(let r=0;r<this.meshData.indexData.length;++r)i[r+s]=this.meshData.indexData[r]+e;this.vertexFrom=e,this.vertexCount=this.meshData.vertexCount,this.indexFrom=s,this.indexCount=this.meshData.indexData.length}static writeAllMeshDataToBuffers(e,t,s){let i=0,r=0;for(const n of e)n.writeMeshDataToBuffers(i,t,r,s),i+=n.vertexCount,r+=n.indexCount}_computeSortKey(){this._sortKey=(31&this.symbolLevel)<<12|(127&this.zOrder)<<4|7&this.geometryType}serialize(e){return e.push(this.geometryType),e.push(this.materialKey),e.push(this.vertexFrom),e.push(this.vertexCount),e.push(this.indexFrom),e.push(this.indexCount),e.push(this.minZoom),e.push(this.maxZoom),e}static deserialize(e,t){const s=e.readInt32(),i=e.readInt32(),r=new U(t.id,s,i);return r.vertexFrom=e.readInt32(),r.vertexCount=e.readInt32(),r.indexFrom=e.readInt32(),r.indexCount=e.readInt32(),r.minZoom=e.readInt32(),r.maxZoom=e.readInt32(),r}}function je(o,e){if(e!==null){o.push(e.length);for(const t of e)t.serialize(o);return o}o.push(0)}function ss(o,e,t){const s=o.readInt32(),i=new Array(s);for(let r=0;r<i.length;r++)i[r]=e.deserialize(o,t);return i}class G{constructor(e){this.insertAfter=null,this.id=e,this.displayRecords=[]}copy(){const e=new G(this.id);return e.set(this),e}clone(){const e=new G(this.id);return e.displayRecords=this.displayRecords.map(t=>t.clone()),e.insertAfter=this.insertAfter,e}set(e){this.id=e.id,this.displayRecords=e.displayRecords,this.insertAfter=e.insertAfter}serialize(e){return e.push(this.id),je(e,this.displayRecords),e}static deserialize(e){const t=e.readInt32(),s=new G(t),i={id:t};return s.displayRecords=ss(e,U,i),s}}class q{get displayObjectRegistry(){if(!this._displayObjectRegistry){this._displayObjectRegistry=new Map;for(const e of this.displayObjects)this._displayObjectRegistry.set(e.id,e)}return this._displayObjectRegistry}get displayList(){return this._displayList}computeDisplayList(){this._displayList=new me;for(const e of this.displayObjects)for(const t of e.displayRecords)this._displayList.addToList(t)}clone(){const e=new q;return this.displayObjects&&(e.displayObjects=this.displayObjects.map(t=>t.clone())),e}serialize(e){return je(e,this.displayObjects),e}_deserializeObjects(e){const t=e.readInt32(),s=new Array(t),i=new Map;for(let r=0;r<s.length;++r){const n=G.deserialize(e);s[r]=n,i.set(n.id,n)}this.displayObjects=s,this._displayList=null,this._displayObjectRegistry=i}static deserialize(e){const t=new q;return t._deserializeObjects(e),t}}class O{constructor(e,t){this.data=e,this.stride=t}static decode(e){const t=ee(e.data,e.stride),s=e.stride;return new O(t,s)}static fromVertexVector(e){const t=ee(e.data.buffer(),e.stride),s=e.stride;return new O(t,s)}}class ${constructor(e,t,s){this.geometryType=e,this.indexBuffer=new Uint32Array(t),this.namedBuffers=s}static decode(e){const t=e.geometryType,s=e.indexBuffer,i={};for(const r in e.namedBuffers)i[r]=O.decode(e.namedBuffers[r]);return new $(t,s,i)}static fromVertexData(e,t){const s=e.indices,i=ee(e.vertices,e.stride),r=e.stride,n={geometry:new O(i,r)};return new $(t,s,n)}static fromVertexVectors(e){const t=e.geometryType,s=e.indexVector.buffer(),i={};for(const r in e.namedVectors)i[r]=O.fromVertexVector(e.namedVectors[r]);return new $(t,s,i)}}class is{constructor(e,t){this.data=e,this.stride=t}get vertexCount(){const e=this.stride/4,t=this.data.length/e;return t!==(0|t)&&console.debug("Corrupted stride"),t}transfer(e,t){const s=this.data.buffer();e.vertexCount=this.vertexCount,e.data=s,e.stride=this.stride,t.push(s)}}class rs{constructor(e,t,s){this.geometryType=e,this.indexVector=new J(Uint32Array,6*t),this.namedVectors={};const i=It(e,s);for(const r in i){const n=i[r];let a;switch(n%4){case 0:case 2:a=new J(Uint32Array,n*t);break;case 1:case 3:a=new J(Uint8Array,n*t)}this.namedVectors[r]=new is(a,n)}}get(e){return this.namedVectors[e].data}getVector(e){return this.namedVectors[e]}transfer(e,t){const s=this.indexVector.buffer(),i={};t.push(s);for(const r in this.namedVectors){const n=this.namedVectors[r];i[r]={},n.transfer(i[r],t)}e.geometryType=this.geometryType,e.indexBuffer=s,e.namedBuffers=i,this.destroy()}intoBuffers(){const e=$.fromVertexVectors(this);return this.destroy(),e}destroy(){this.indexVector=null,this.namedVectors=null}}const Q=new ke,S=new ke,Ie=1.5,ns=5;function os(o,e){const t={};for(const s in o){const i={data:pe(e,o[s]),stride:o[s]};t[s]=i}return t}function as(o){return[o.fill||{},o.line||{},o.icon||{},o.text||{},o.label||{}]}function ls(o){const e=[[],[],[],[],[]],t=o;for(const s of t)for(const i of s.displayRecords)e[i.geometryType].push(i);return e}class D{constructor(){this.tileDisplayData=null,this.tileBufferData=null}reshuffle(){Q.reset();const e=ls(this.tileDisplayData.displayObjects);for(const i of e)for(const r of i)r&&Q.needMore(r.geometryType,r.meshData?r.meshData.vertexCount:r.vertexCount,r.meshData?r.meshData.indexData.length:r.indexCount);const t=e.length,s=new z;for(let i=0;i<t;++i){s.geometries[i].indexBuffer=new Uint32Array(Math.round(Ie*Q.indicesFor(i)));const r=[];for(const d in this.tileBufferData.geometries[i].vertexBuffer)r.push(this.tileBufferData.geometries[i].vertexBuffer[d].stride);const n=D._computeVertexAlignment(r),a=Math.round(Ie*Q.verticesFor(i)),l=D._align(a,n);for(const d in this.tileBufferData.geometries[i].vertexBuffer){const h=this.tileBufferData.geometries[i].vertexBuffer[d].stride;s.geometries[i].vertexBuffer[d]={stride:h,data:pe(l,h)}}}S.reset(),this.tileDisplayData.displayList.clear();for(let i=0;i<t;++i){const r=e[i];for(const n of r){if(n.meshData)n.writeMeshDataToBuffers(S.verticesFor(i),s.geometries[i].vertexBuffer,S.indicesFor(i),s.geometries[i].indexBuffer),n.meshData=null;else{const a=this.tileBufferData.geometries[i].vertexBuffer,l=this.tileBufferData.geometries[i].indexBuffer,d=s.geometries[i].vertexBuffer,h=s.geometries[i].indexBuffer,c=S.verticesFor(i),u=S.indicesFor(i);ce(c,u,d,h,n,a,l),n.vertexFrom=c,n.indexFrom=u}S.needMore(i,n.vertexCount,n.indexCount)}}for(const i of this.tileDisplayData.displayObjects)this.tileDisplayData.displayList.addToList(i.displayRecords);this.tileBufferData=s}getStrides(){const e=[];for(let t=0;t<this.tileBufferData.geometries.length;++t){const s=this.tileBufferData.geometries[t];e[t]={};for(const i in s.vertexBuffer)e[t][i]=s.vertexBuffer[i].stride}return e}clone(){const e=new D;return e.tileBufferData=this.tileBufferData.clone(),e.tileDisplayData=this.tileDisplayData.clone(),e}_guessSize(){const{displayObjects:e}=this.tileDisplayData,t=Math.min(e.length,4),s=12,i=40;let r=0;for(let n=0;n<t;n++)r=Math.max(r,e[n].displayRecords.length);return 2*(e.length*s+e.length*r*i)}serialize(){const e=this.tileBufferData.serialize(),t=this.tileBufferData.getBuffers(),s=this.tileDisplayData.serialize(new J(Int32Array,this._guessSize())).buffer();return t.push(s),{result:{displayData:s,bufferData:e},transferList:t}}static fromVertexData(e,t){const s={},i=new Map;for(const r of t)i.set(r.id,r);return St(r=>{const n=e.data[r];if(F(n)){const a=Gt.from(n.records).getCursor();for(;a.next();){const l=a.id,d=a.materialKey,h=a.indexFrom,c=a.indexCount,u=a.vertexFrom,p=a.vertexCount,f=i.get(l),m=new U(l,r,d);m.indexFrom=h,m.indexCount=c,m.vertexFrom=u,m.vertexCount=p,f.displayRecords.push(m)}s[r]=$.fromVertexData(n,r)}else s[r]=new rs(r,0,Ue.DEFAULT).intoBuffers()}),D.fromMeshData({displayObjects:t,vertexBuffersMap:s})}static fromMeshData(e){const t=new D,s=new q,i=new z;s.displayObjects=e.displayObjects;for(const r in e.vertexBuffersMap){const n=e.vertexBuffersMap[r];i.geometries[r].indexBuffer=n.indexBuffer,i.geometries[r].vertexBuffer=n.namedBuffers}return t.tileDisplayData=s,t.tileBufferData=i,t}static bind(e,t){const s=new D;return s.tileDisplayData=e,s.tileBufferData=t,s}static create(e,t){const s=new D;s.tileDisplayData=new q,s.tileDisplayData.displayObjects=e;const i=[0,0,0,0,0],r=[0,0,0,0,0],n=[[],[],[],[],[]];for(const d of e)for(const h of d.displayRecords)n[h.geometryType].push(h),i[h.geometryType]+=h.meshData.vertexCount,r[h.geometryType]+=h.meshData.indexData.length;const a=new z,l=as(t);for(let d=0;d<ns;d++){const h=new Uint32Array(r[d]),c=os(l[d],i[d]);U.writeAllMeshDataToBuffers(n[d],c,h),a.geometries[d]={indexBuffer:h,vertexBuffer:c}}return s.tileBufferData=a,s}static _align(e,t){const s=e%t;return s===0?e:e+(t-s)}static _computeVertexAlignment(e){let t=!1,s=!1;for(const i of e)i%4==2?t=!0:i%4!=0&&(s=!0);return s?4:t?2:1}}const M=512,T=50;function hs(o,e){const t=E(e);if(!t)return null;const[s,i]=t.valid;return o[2]>i?[b([o[0],o[1],i,o[3]]),b([s,o[1],s+o[2]-i,o[3]])]:o[0]<s?[b([s,o[1],o[2],o[3]]),b([i-(s-o[0]),o[1],i,o[3]])]:null}function ds(o){return o==="text"||o==="esriTS"}function cs(o){return o==="simple-marker"||o==="picture-marker"||o==="esriSMS"||o==="esriPMS"}function Se(o){switch(Ee(o.geometry).type){case"point":case"multipoint":return 0;case"polyline":return 1;case"polygon":case"extent":return 2}return 0}function us(o){if(!o)return null;const{xmin:e,ymin:t,xmax:s,ymax:i,spatialReference:r}=o;return new Ke({rings:[[[e,t],[e,i],[s,i],[s,t],[e,t]]],spatialReference:r})}class ie extends Et{constructor(e,t,s){super(e,t,null),this._transform=s}static from(e,t,s){const i=qt.createInstance(),r=[],n=e.filter(a=>!!a.geometry);for(const a of n){const l=fe(a.geometry);qe(r,[a],l,!1,!1,t)}return new ie(i,r,s)}get geometryType(){const e=this._current;return e?e.geometryType:null}get insertAfter(){return this._current.insertAfter}readGraphic(){return this._current}getCursor(){return this.copy()}copy(){const e=new ie(this.instance,this._features,this._transform);return this.copyInto(e),e}}const V=new Ge,le=new Ge,Me="esriGeometryPolyline";function Le(o){o.coords.length=0,o.lengths.length=0}class R{constructor(){this.bounds=b(),this.graphic=null}static acquire(e=null,t,s,i,r){let n;return R._pool.length===0?n=new R:(n=R._pool.pop(),this._set.delete(n)),n.acquire(e,t,s,i,r),n}static release(e){e&&!this._set.has(e)&&(e.release(),this._pool.push(e),this._set.add(e))}static getCentroidQuantized(e,t){if(de(e.geometry)){const s=e.symbol;if(A(s))return null;if((s==null?void 0:s.layers.length)>0&&s.layers.some(i=>i.type==="text"||i.type==="marker")){const i=He(e.geometry);return i!==null?Zt(t,{},{x:i[0],y:i[1]},!1,!1):null}}return null}acquire(e=null,t,s,i,r){e&&this.set(e,t,s,i,r)}release(){this.graphic=null,this.symbolResource=null,this.geometry=null}get symbol(){return this.symbolResource.symbol}set(e,t,s,i,r){this.graphic=e,this.geometry=s,this.symbolResource=t,this.bounds=i,r&&(this.size=r)}getGeometryQuantized(e,t,s,i){const r=this.geometry,n=fe(r);if(A(n))return null;switch(n){case"esriGeometryPolygon":{const a=r,{rings:l}=a;if(!l||l.length===0)return null;let d;if(d=l.length===1&&l[0].length===2?P(e,{paths:[[l[0][0],l[0][1]]]}):P(e,this.geometry),!d){const h={x:l[0][0][0],y:l[0][0][1]};if(d=P(e,h),d){const{x:c,y:u}=d;return{rings:[[[c-1,u],[1,-1],[1,1],[-1,1],[-1,-1]]]}}}return d}case"esriGeometryPolyline":{const a=r;return Le(V),Le(le),Ne(V,a),Ze(le,V,a.hasZ,a.hasM,Me,e.scale[0]),Ye(V,le,a.hasZ,a.hasM,Me,e),Qe(V,a.hasZ,a.hasM)}case"esriGeometryMultipoint":{const a=r,l=.5*i*Math.max(Math.abs(this.size[0])+this.size[2]-this.size[0],Math.abs(this.size[1])+this.size[3]-this.size[1]),d=E(s);let h=a.points;if(d){const[c,u]=d.valid,p=u-c;h=h.filter(f=>{if(f[0]+l>u||f[0]-l<c){const m=[...f];return f[0]+l>u?m[0]-=p:m[0]+=p,ne(t,f,l)||ne(t,m,l)}return ne(t,f,l)})}return h.length===0?{points:h}:P(e,{points:h})}}return P(e,this.geometry)}}R._pool=[],R._set=new Set;const k={minX:0,minY:0,maxX:0,maxY:0},L=b(),Ae=1e-5;function W(o,e,t,s,i){return k.minX=e,k.minY=t,k.maxX=s,k.maxY=i,o.search(k)}function fs(o){return{minX:o.bounds[0],minY:o.bounds[1],maxX:o.bounds[2],maxY:o.bounds[3]}}class ps{constructor(e,t,s,i,r,n,a){this._graphics=i,this._onAdd=r,this._onRemove=n,this._hashToCIM=a,this._index=We(9,fs),this._itemByGraphic=new Map,this._inflatedSizeHelper=new Ce,this._tileInfoView=e,this._uidFieldName=s;const l=e.getClosestInfoForScale(t);l&&(this._resolution=this._tileInfoView.getTileResolution(l.level))}setResourceManager(e){this._cimResourceManager=e,this._hittestDrawHelper=new vt(e)}hitTest(e,t,s,i,r){e=Oe(e,this._tileInfoView.spatialReference);const n=.5*i*window.devicePixelRatio*s;L[0]=e-n,L[1]=t-n,L[2]=e+n,L[3]=t+n;const a=.5*i*(s+T),l=W(this._index,e-a,t-a,e+a,t+a);if(!l||l.length===0)return[];const d=[],h=b(),c=b();for(const f of l){const{geometry:m,symbolResource:_}=f;this._getSymbolBounds(h,_,m,c,r),c[3]=c[2]=c[1]=c[0]=0,Xe(h,L)&&f.graphic.visible&&d.push(f)}if(d.length===0)return[];const u=this._hittestDrawHelper,p=[];for(const f of d){const{geometry:m,symbolResource:_}=f,{hash:y,textInfo:I}=_,H=this._hashToCIM.get(y);H&&u.hitTest(L,H.symbol,m,I,r,i)&&p.push(f)}return p.sort(ms),p.map(f=>f.graphic)}getGraphicsData(e,t,s){const i=this._searchForItems(t);if(i.length===0||s.length===0)return[];i.sort((c,u)=>c.zorder-u.zorder),i[0].insertAfter=-1;for(let c=1;c<i.length;c++)i[c].insertAfter=i[c-1].graphic.uid;i.sort((c,u)=>c.graphic.uid-u.graphic.uid),s.sort((c,u)=>c.uid-u.uid);let r,n=0,a=0;const l=t.resolution,d=[],h={originPosition:"upperLeft",scale:[l,l],translate:[t.bounds[0],t.bounds[3]]};for(const c of s){for(a=-2;n<i.length;)if(r=i[n],n++,c.uid===r.graphic.uid){a=r.insertAfter;break}if(!r.geometry||a===-2)continue;const u=r.getGeometryQuantized(h,t.bounds,this._tileInfoView.spatialReference,l),p={...r.graphic.attributes};p[this._uidFieldName]=c.uid,r.groupId==null&&(r.groupId=e.createTemplateGroup(r.symbol,null)),d.push({centroid:R.getCentroidQuantized(r,h),geometry:u,attributes:p,symbol:r.symbol,groupId:r.groupId,insertAfter:a,zorder:r.zorder})}return d.sort((c,u)=>c.zorder-u.zorder),d}queryTileData(e,t){if(this._graphics.length===0)return[];const{bounds:s,resolution:i}=t,r=this._searchForItems(t),n=[];return r.length===0||this._createTileGraphics(n,e,r,{originPosition:"upperLeft",scale:[i,i],translate:[s[0],s[3]]},t),n}has(e){return this._itemByGraphic.has(e)}getBounds(e){const t=this._itemByGraphic.get(e);return t?t.bounds:null}getAllBounds(){return Array.from(this._itemByGraphic.values()).filter(e=>e.graphic.visible).map(e=>e.bounds)}addOrModify(e,t,s){if(!e||A(t))return;this.has(e)&&this.remove(e),this._onAdd(e);const i=[0,0,0,0],r=this._getSymbolBounds(null,t,s,i,0),n=R.acquire(e,t,s,F(r)?r:null,i);return this._itemByGraphic.set(e,n),s&&this._index.insert(n),n.bounds}remove(e){if(!this._itemByGraphic.has(e))return;this._onRemove(e);const t=this._itemByGraphic.get(e);t.bounds&&this._index.remove(t),this._itemByGraphic.delete(e)}updateZ(){const e=this._graphics.items;let t,s;for(let i=0;i<e.length;i++)s=e[i],t=this._itemByGraphic.get(s),t&&(t.zorder=i)}update(e,t,s){const i=this._itemByGraphic.get(e);i.groupId=null;const r=Je(i.bounds);this._index.remove(i);const n=this._getSymbolBounds(i.bounds,t,s,i.size,0);return F(n)&&i.set(e,t,s,n,i.size),s&&this._index.insert(i),{oldBounds:r,newBounds:i.bounds}}updateLevel(e){if(this._resolution===e)return;this._resolution=e,this._index.clear();const t=this._itemByGraphic,s=[];for(const[i,r]of t){const n=this._getSymbolBounds(r.bounds,r.symbolResource,r.geometry,r.size,0);r.geometry&&F(n)&&(r.bounds=n,s.push(r))}this._index.load(s)}clear(){this._itemByGraphic.clear(),this._index.clear()}_createTileGraphics(e,t,s,i,r){const n=this._uidFieldName,a=this._tileInfoView.spatialReference,{bounds:l,resolution:d}=r;let h,c,u,p;s.sort((f,m)=>f.zorder-m.zorder);for(let f=0;f<s.length;f++){u=s[f],h=u.graphic,c=u.getGeometryQuantized(i,l,a,d),p=f===0?-1:s[f-1].graphic.uid;const m={...u.graphic.attributes};m[n]=h.uid,u.groupId==null&&(u.groupId=t.createTemplateGroup(u.symbol,null)),e.push({centroid:R.getCentroidQuantized(u,i),geometry:c,attributes:m,symbol:u.symbol,groupId:u.groupId,insertAfter:p,zorder:u.zorder})}}_searchForItems(e){const t=this._tileInfoView.spatialReference,s=e.bounds;if(t.isWrappable){const[i,r]=E(t).valid,n=Math.abs(s[2]-r)<Ae,a=Math.abs(s[0]-i)<Ae;if((!n||!a)&&(n||a)){const l=e.resolution;let d;d=b(n?[i,s[1],i+l*T,s[3]]:[r-l*T,s[1],r,s[3]]);const h=W(this._index,s[0],s[1],s[2],s[3]),c=W(this._index,d[0],d[1],d[2],d[3]);return[...new Set([...h,...c])]}}return W(this._index,s[0],s[1],s[2],s[3])}_getSymbolBounds(e,t,s,i,r){if(!t||!t.symbol||!s)return null;if(e||(e=b()),et(e,s),!i||i[0]===0&&i[1]===0&&i[2]===0&&i[3]===0){const{hash:l,textInfo:d}=t,h=this._hashToCIM.get(l);if(!h)return null;i||(i=[0,0,0,0]);const c=this._inflatedSizeHelper.getSymbolInflateSize(i,h.symbol,this._cimResourceManager,r,d);i[0]=N(c[0]),i[1]=N(c[1]),i[2]=N(c[2]),i[3]=N(c[3])}const n=this._resolution,a=Ce.safeSize(i);return e[0]-=a*n,e[1]-=a*n,e[2]+=a*n,e[3]+=a*n,e}}const ms=(o,e)=>{const t=Se(o.graphic),s=Se(e.graphic);return t===s?e.zorder-o.zorder:t-s},gs=o=>{let e=class extends tt(o){constructor(){super(...arguments),this.graphics=null,this.renderer=null}};return v([C()],e.prototype,"graphics",void 0),v([C()],e.prototype,"renderer",void 0),v([C()],e.prototype,"updating",void 0),v([C()],e.prototype,"view",void 0),e=v([$e("esri.views.layers.GraphicsView")],e),e},ys=st("esri-2d-graphic-debug");function he(o,e,t){if(t.has(o))return t.get(o);const s={tile:e,addedOrModified:[],removed:[]};return t.set(o,s),s}let w=class extends gs(it(ft)){constructor(o){super(o),this._storage=new Ht,this._displayIds=new Map,this._controller=new AbortController,this._tiles=new Map,this._graphicStoreUpdate=!1,this._graphicsSet=new Set,this._matcher=Promise.resolve(null),this._tileUpdateSet=new Set,this._tilesToUpdate=new Map,this._graphicIdToAbortController=new Map,this._attached=!1,this._updatingGraphicsTimer=null,this._hashToExpandedSymbol=new Map,this._hashToExpandedSymbolPromise=new Map,this._hashToCIMSymbolPromise=new Map,this._hashToCIM=new Map,this._processing=!1,this._needsProcessing=!1,this._pendingUpdate={added:new Set,updated:new Set,removed:new Set},this.lastUpdateId=-1,this.updateRequested=!1,this.graphicUpdateHandler=this.graphicUpdateHandler.bind(this)}destroy(){this._updatingGraphicsTimer&&(clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=null,this.notifyChange("updating")),this._controller.abort(),this.container.destroy(),this._set("graphics",null),this._graphicStore.clear(),this._attributeStore=null,this._hashToExpandedSymbol.clear(),this.view=null,this.renderer=null,this._hashToCIM.clear(),this._hashToCIMSymbolPromise.clear(),this._hashToExpandedSymbolPromise.clear()}_createMatcher(o,e,t){if(o){const s=we(o),i=Kt({indexCount:0,fields:{}},"feature",o,s);this._matcher=Ut(i,e,null,t)}}_createDisplayId(o){return this._displayIds.has(o)||this._displayIds.set(o,this._storage.createDisplayId()),this._displayIds.get(o)}initialize(){this._attributeStore=new Nt({type:"local",initialize:i=>Promise.resolve(this.container.attributeView.initialize(i)),update:i=>this.container.attributeView.requestUpdate(i),render:()=>this.container.requestRender()},rt("2d"),()=>this.notifyChange("updating")),this.container.hasHighlight=()=>this._attributeStore.hasHighlight;const o=i=>{this._createDisplayId(i.uid),this._setFilterState(i.uid,i.visible)},e=i=>{const r=this._displayIds.get(i.uid);this._displayIds.delete(i.uid),this._storage.releaseDisplayId(r)},t=new Pt(this.container.getMaterialItems.bind(this.container),this.view.featuresTilingScheme.tileInfo);this._graphicStore=new ps(this.view.featuresTilingScheme,this.view.state.scale,this.uid,this.graphics,o,e,this._hashToCIM),this._meshFactory=new Vt(null,this.uid,t),this._templateStore=t,this.handles.add([nt(()=>this.renderer,i=>{this._createMatcher(i,t,this.container.stage.resourceManager);for(const r of this.graphics)this._pendingUpdate.updated.add(r);this.requestUpdate()}),this.view.graphicsTileStore.on("update",this._onTileUpdate.bind(this)),this.container.on("attach",()=>{ys&&this.container.enableRenderingBounds(()=>this._graphicStore.getAllBounds()),this.graphics.items.length>0&&this._graphicsChangeHandler({target:this.graphics,added:this.graphics.items,removed:[],moved:[]}),this.handles.add(this.graphics.on("change",r=>this._graphicsChangeHandler(r)),"graphics");const i=this.container.stage.resourceManager;this._createMatcher(this.renderer,t,i),this._graphicStore.setResourceManager(i),this._attached=!0,this.notifyChange("updating")})]);const s=this.view.graphicsTileStore.tiles;this._onTileUpdate({added:s,removed:[]})}get updating(){return!this._attached||this._updatingGraphicsTimer!==null||this._tileUpdateSet.size>0||this._tilesToUpdate.size>0||this._attributeStore.isUpdating()}hitTest(o){if(!this.view||!this.view.position)return[];const{resolution:e,rotation:t}=this.view.state;return this._graphicStore.hitTest(o.x,o.y,2,e,t)}update(o){x(this._controller.signal);const e=o.state,{resolution:t}=e;if(this._graphicStore.updateLevel(t),this._graphicStoreUpdate=!0,this.updateRequested=!1,this._pendingUpdate.updated.size>0){if(!this._processing)return void this._updateGraphics();this._needsProcessing=!0}}viewChange(){this.requestUpdate()}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.requestUpdateCallback())}processUpdate(o){this.updateRequested&&(this.updateRequested=!1,this.update(o))}graphicUpdateHandler(o){const{graphic:e,property:t}=o;switch(t){case"attributes":case"geometry":case"symbol":this._pendingUpdate.updated.add(e),this.requestUpdate();break;case"visible":this._setFilterState(e.uid,e.visible),this._attributeStore.sendUpdates()}}setHighlight(o){const e=o.map(t=>this._displayIds.get(t));this._attributeStore.setHighlight(o,e)}_getIntersectingTiles(o){const e=this._graphicStore.getBounds(o);if(!e||ot(e)===0||at(e)===0)return[];const t=hs(e,this.view.spatialReference);return F(t)?[...new Set([...this.view.graphicsTileStore.boundsIntersections(t[0]),...this.view.graphicsTileStore.boundsIntersections(t[1])])]:this.view.graphicsTileStore.boundsIntersections(e)}async _updateTile(o){x(this._controller.signal);const e=o.tile,t=this._getGraphicsData(this._templateStore,e,o.addedOrModified),s=await this._processGraphics(e,t);return x(this._controller.signal),this._patchTile(e.key,{type:"update",addOrUpdate:s,remove:o.removed,end:!0,clear:!1,sort:!1}),s}_patchTile(o,e){if(!this._tiles.has(o))return;const t=this._tiles.get(o);this.container.onTileData(t,e),this.container.requestRender()}_graphicsChangeHandler(o){const e=this._pendingUpdate;for(const t of o.added)e.added.add(t);for(const t of o.moved)e.updated.add(t);for(const t of o.removed)this._pendingUpdate.added.has(t)?e.added.delete(t):e.removed.add(t);this._processing?this._needsProcessing=!0:this._updateGraphics()}_getGraphicsToUpdate(){const o={added:[],removed:[],updated:[]};if(!this.graphics)return o;const e=this._pendingUpdate;for(const t of this.graphics.items)e.added.has(t)?o.added.push(t):e.updated.has(t)&&o.updated.push(t);for(const t of e.removed)this._graphicStore.has(t)&&o.removed.push(t);return e.added.clear(),e.removed.clear(),e.updated.clear(),o}async _updateGraphics(){this._processing=!0;const{added:o,removed:e,updated:t}=this._getGraphicsToUpdate(),s=this._tilesToUpdate;let i;try{if(!this._graphicStoreUpdate){const h=this.view.state,{resolution:c}=h;this._graphicStore.updateLevel(c)}const r=[],n=new Array(o.length+e.length);for(let h=0;h<t.length;h++){const c=t[h],u=this._getIntersectingTiles(c);for(const p of u)i=p.id,he(i,p,s).removed.push(this._displayIds.get(c.uid));r.push(this._updateGraphic(c,null)),n[h]=c}const a=t.length;for(let h=0;h<o.length;h++){const c=o[h];n[a+h]=c,this._graphicsSet.add(c),r.push(this._addGraphic(c))}for(const h of e){this._abortProcessingGraphic(h.uid);const c=this._getIntersectingTiles(h);for(const u of c)i=u.id,he(i,u,s).removed.push(this._displayIds.get(h.uid));this._graphicsSet.delete(h),this._graphicStore.remove(h)}let l;this._flipUpdatingGraphics(),await Promise.all(r);for(let h=0;h<n.length;h++){l=n[h];const c=this._getIntersectingTiles(l);for(const u of c)i=u.id,he(i,u,s).addedOrModified.push(l)}this._graphicStore.updateZ();const d=[];for(const[h,c]of s)d.push(this._updateTile(c));await Promise.all(d)}catch(r){Z(r)}for(const r of e)try{const n=await this._getSymbolForGraphic(r,null);if(n){const a=n.hash();this._hashToExpandedSymbol.delete(a)}}catch(n){Z(n)}s.clear(),this.notifyChange("updating"),this._processing=!1,this._needsProcessing&&(this._needsProcessing=!1,this._updateGraphics())}_getArcadeInfo(o){const e=(o.attributes?Object.keys(o.attributes):[]).map(t=>({name:t,alias:t,type:typeof o.attributes[t]=="string"?"esriFieldTypeString":"esriFieldTypeDouble"}));return A(o.geometry)?null:{geometryType:fe(o.geometry),spatialReference:lt.fromJSON(o.geometry.spatialReference),fields:e}}_getSymbolForGraphic(o,e){return x(this._controller.signal),F(o.symbol)?Promise.resolve(o.symbol):F(this.renderer)?this.renderer.getSymbolAsync(o,{scale:this.view.scale,signal:F(e)?e.signal:null}):Promise.resolve(this._getNullSymbol(o))}_getCIMSymbol(o,e,t){let s=this._hashToCIM.get(e);if(s)return Promise.resolve(s);const i=bt(o);if(F(i)){if(i.type==="CIMSymbolReference")return s=i,this._hashToCIM.set(e,s),Promise.resolve(s);let r=this._hashToCIMSymbolPromise.get(e);return r||(r=i.fetchCIMSymbol(t).then(n=>(this._hashToCIM.set(e,n.data),this._hashToCIMSymbolPromise.delete(e),n)).catch(n=>(this._hashToCIMSymbolPromise.delete(e),_e(n),null)),this._hashToCIMSymbolPromise.set(e,r),r)}return Promise.resolve(null)}_expandCIMSymbol(o,e,t,s){const i=this._hashToExpandedSymbol.get(t);if(i)return Promise.resolve(i);let r=this._hashToExpandedSymbolPromise.get(t);if(r)return r;const n=this.container.stage,a=this._getArcadeInfo(e),l=we(null),d=Yt(o,l);return r=kt(d,a,n.resourceManager,s),this._hashToExpandedSymbolPromise.set(t,r),r.then(h=>(this._hashToExpandedSymbol.set(t,h),this._hashToExpandedSymbolPromise.delete(t),h)),r}async _getSymbolResources(o,e){return x(this._controller.signal),this.container.stage?this._getSymbolForGraphic(o,e).then(t=>{const s=t.hash();return this._getCIMSymbol(t,s,e).then(i=>A(i)?null:this._expandCIMSymbol(i,o,s,e).then(r=>{const n=r.layers.filter(a=>a.type==="text"&&typeof a.text=="string");if(n&&n.length>0){const a=new Array(n.length);for(let d=0;d<n.length;d++){const h=n[d],c=[],[u]=Dt(h.text);h.text=u;for(let p=0;p<u.length;p++)c.push(u.charCodeAt(p));a[d]={symbol:h,id:d,glyphIds:c}}const l=new Map;return this.container.getMaterialItems(a).then(d=>{for(let h=0;h<n.length;h++){const c=n[h];l.set(c.cim,{text:c.text,mosaicItem:d[h].mosaicItem})}return{symbol:r,textInfo:l,hash:s}})}return{symbol:r,hash:s}}))}).catch(t=>(_e(t),null)):null}async _projectAndNormalizeGeometry(o,e){if(x(this._controller.signal),A(o.geometry)||o.geometry.type==="mesh")return null;let t=o.geometry;if(de(t)){const r=t.rings;t.rings=r}else if(xe(t)){const r=t.paths;t.paths=r}else if(ve(t)){const r=await this._getSymbolForGraphic(o,e);x(this._controller.signal),cs(r.type)||ds(r.type)?t=t.center:t=us(t)}await Bt(t.spatialReference,this.view.spatialReference);const s=Ct(t),i=wt(s,t.spatialReference,this.view.spatialReference);return i&&ht(i),i}_onTileUpdate(o){const e=E(this.view.spatialReference);if(o.added&&o.added.length>0)for(const t of o.added)this._addNewTile(t,e);if(o.removed&&o.removed.length>0)for(const t of o.removed)this._removeTile(t.key)}async _addGraphic(o){this._abortProcessingGraphic(o.uid),x(this._controller.signal);const e=new AbortController;this._graphicIdToAbortController.set(o.uid,e);const t={signal:e.signal};try{await this._addOrUpdateGraphic(o,t),x(this._controller.signal),this._graphicIdToAbortController.delete(o.uid)}catch(s){if(this._graphicIdToAbortController.delete(o.uid),!Z(s))throw s}}_updateGraphic(o,e){x(this._controller.signal);const t=this._projectAndNormalizeGeometry(o,e),s=this._getSymbolResources(o,e);return Promise.all([t,s]).then(([i,r])=>{x(this._controller.signal),this._graphicStore.addOrModify(o,r,i)})}_addOrUpdateGraphic(o,e){x(this._controller.signal);const t=this._projectAndNormalizeGeometry(o,e),s=this._getSymbolResources(o,e);return Promise.all([t,s]).then(([i,r])=>{x(this._controller.signal),this._graphicsSet.has(o)&&this._graphicStore.addOrModify(o,r,i)})}_addTile(o){const e=this.view.featuresTilingScheme.getTileBounds(b(),o),t=this.view.featuresTilingScheme.getTileResolution(o.level),s=new ts(o,t,e[0],e[3]);return this._tiles.set(o,s),this.container.addChild(s),s}async _addNewTile(o,e){const t=this._addTile(o.key),s=this._graphicStore.queryTileData(this._templateStore,o);if(s.length===0)return;if(e){const r=Math.round((e.valid[1]-e.valid[0])/o.resolution);for(const n of s)n.geometry&&(be(n.geometry)||oe(n.geometry))&&this._wrapPoints(n,r)}const i=o.key;this._tileUpdateSet.add(o.key),this.notifyChange("updating");try{const r={type:"update",clear:!1,addOrUpdate:await this._processGraphics(o,s),remove:[],end:!0,sort:!1};t.patch(r),this._tileUpdateSet.delete(i),this.notifyChange("updating")}catch(r){if(this._tileUpdateSet.delete(i),this.notifyChange("updating"),!Z(r))throw r}}_removeTile(o){if(!this._tiles.has(o))return;const e=this._tiles.get(o);this.container.removeChild(e),e.destroy(),this._tiles.delete(o)}_setFilterState(o,e){const t=this._displayIds.get(o),s=this._attributeStore.getHighlightFlag(o);this._attributeStore.setData(t,0,0,s|(e?Tt:0))}_getGraphicsData(o,e,t){const s=this.view,i=E(s.spatialReference),r=this._graphicStore.getGraphicsData(o,e,t);if(i){const n=Math.round((i.valid[1]-i.valid[0])/e.resolution);for(const a of r)a.geometry&&(be(a.geometry)||oe(a.geometry))&&this._wrapPoints(a,n)}return r}_wrapPoints(o,e){const t=o.geometry;oe(t)?this._wrapMultipoint(t,e):this._wrapPoint(o,e)}_wrapMultipoint(o,e){const t=o.points,s=[];let i=0,r=0;for(const[n,a]of t){if(s.push([n+i,a]),i=0,e===M){const l=5*T;n+r<l?(s.push([e,0]),i=-e):n+r>M-l&&(s.push([-e,0]),i=e)}else n+r<-T?(s.push([e,0]),i=-e):n+r>M+T&&(s.push([-e,0]),i=e);r+=n}o.points=s}_wrapPoint(o,e){const t=o.geometry;if(e===M){const s=5*T;t.x<s?o.geometry={points:[[t.x,t.y],[e,0]]}:t.x>M-s&&(o.geometry={points:[[t.x,t.y],[-e,0]]})}else t.x<-T?o.geometry={points:[[t.x,t.y],[e,0]]}:t.x>M+T&&(o.geometry={points:[[t.x,t.y],[-e,0]]})}_processGraphics(o,e,t){if(!(e&&e.length)||!this._meshFactory)return null;const s=ie.from(e,this.uid,o.transform),i=this._meshFactory;return this._matcher.then(r=>i.analyzeGraphics(s,this.container.stage.resourceManager,r,null,null,t).then(()=>(this._attributeStore.sendUpdates(),this._processAnalyzedGraphics(o,s))))}_processAnalyzedGraphics(o,e){const t=this._meshFactory,s=e.getSize(),i=e.getCursor(),r={features:s,records:s,metrics:0},n=new jt(o.key.id,r,Ue.DEFAULT,!1,!1),a=[];for(;i.next();){const c=i.readGraphic();c.insertAfter=c.insertAfter===-1?-1:this._displayIds.get(c.insertAfter),c.displayId=this._displayIds.get(c.attributes[this.uid]);const u=new G(c.displayId);u.insertAfter=c.insertAfter,a.push(u),t.writeGraphic(n,i,o.level,this.container.stage.resourceManager)}const l=o.tileInfoView.tileInfo.isWrappable,d=n.serialize(l);if(d.length!==1)return new D;const h=d[0].message;return D.fromVertexData(h,a)}_abortProcessingGraphic(o){this._graphicIdToAbortController.has(o)&&this._graphicIdToAbortController.get(o).abort()}_getNullSymbol(o){const e=o.geometry;return xe(e)?dt:de(e)||ve(e)?ct:ut}_flipUpdatingGraphics(){this._updatingGraphicsTimer&&clearTimeout(this._updatingGraphicsTimer),this._updatingGraphicsTimer=setTimeout(()=>{this._updatingGraphicsTimer=null,this.notifyChange("updating")},160),this.notifyChange("updating")}};v([C({constructOnly:!0})],w.prototype,"requestUpdateCallback",void 0),v([C()],w.prototype,"container",void 0),v([C({constructOnly:!0})],w.prototype,"graphics",void 0),v([C()],w.prototype,"updating",null),v([C()],w.prototype,"view",void 0),v([C()],w.prototype,"updateRequested",void 0),w=v([$e("esri.views.2d.layers.support.GraphicsView2D")],w);const Us=w,_s=Math.PI/180,xs=4;class vs extends Wt{constructor(e){super(),this._dvsMat3=De(),this._localOrigin={x:0,y:0},this._getBounds=e}destroy(){this._vao&&(this._vao.dispose(!0),this._vao=null,this._vertexBuffer=null,this._indexBuffer=null),this._program&&(this._program.dispose(),this._program=null)}doRender(e){const{context:t}=e,s=this._getBounds();if(s.length<1)return;this._createShaderProgram(t),this._updateMatricesAndLocalOrigin(e),this._updateBufferData(t,s),t.setBlendingEnabled(!0),t.setDepthTestEnabled(!1),t.setStencilWriteMask(0),t.setStencilTestEnabled(!1),t.setBlendFunction(Be.ONE,Be.ONE_MINUS_SRC_ALPHA),t.setColorMask(!0,!0,!0,!0);const i=this._program;t.bindVAO(this._vao),t.useProgram(i),i.setUniformMatrix3fv("u_dvsMat3",this._dvsMat3),t.gl.lineWidth(1),t.drawElements(Lt.LINES,8*s.length,Ve.UNSIGNED_INT,0),t.bindVAO()}_createTransforms(){return{dvs:De()}}_createShaderProgram(e){if(this._program)return;const t=`precision highp float;
  2. uniform mat3 u_dvsMat3;
  3. attribute vec2 a_position;
  4. void main() {
  5. mediump vec3 pos = u_dvsMat3 * vec3(a_position, 1.0);
  6. gl_Position = vec4(pos.xy, 0.0, 1.0);
  7. }`,s=`precision mediump float;
  8. void main() {
  9. gl_FragColor = vec4(0.75, 0.0, 0.0, 0.75);
  10. }`;this._program=e.programCache.acquire(t,s,ze().attributes)}_updateMatricesAndLocalOrigin(e){const{state:t}=e,{displayMat3:s,size:i,resolution:r,pixelRatio:n,rotation:a,viewpoint:l}=t,d=_s*a,{x:h,y:c}=l.targetGeometry,u=Oe(h,t.spatialReference);this._localOrigin.x=u,this._localOrigin.y=c;const p=n*i[0],f=n*i[1],m=r*p,_=r*f,y=pt(this._dvsMat3);mt(y,y,s),gt(y,y,yt(p/2,f/2)),_t(y,y,Qt(i[0]/m,-f/_,1)),xt(y,y,-d)}_updateBufferData(e,t){const{x:s,y:i}=this._localOrigin,r=2*xs*t.length,n=new Float32Array(r),a=new Uint32Array(8*t.length);let l=0,d=0;for(const h of t)h&&(n[2*l+0]=h[0]-s,n[2*l+1]=h[1]-i,n[2*l+2]=h[0]-s,n[2*l+3]=h[3]-i,n[2*l+4]=h[2]-s,n[2*l+5]=h[3]-i,n[2*l+6]=h[2]-s,n[2*l+7]=h[1]-i,a[d+0]=l+0,a[d+1]=l+3,a[d+2]=l+3,a[d+3]=l+2,a[d+4]=l+2,a[d+5]=l+1,a[d+6]=l+1,a[d+7]=l+0,l+=4,d+=8);if(this._vertexBuffer?this._vertexBuffer.setData(n.buffer):this._vertexBuffer=te.createVertex(e,ue.DYNAMIC_DRAW,n.buffer),this._indexBuffer?this._indexBuffer.setData(a):this._indexBuffer=te.createIndex(e,ue.DYNAMIC_DRAW,a),!this._vao){const h=ze();this._vao=new Pe(e,h.attributes,h.bufferLayouts,{geometry:this._vertexBuffer},this._indexBuffer)}}}const ze=()=>Mt("bounds",{geometry:[{location:0,name:"a_position",count:2,type:Ve.FLOAT}]});class Ps extends Ot{constructor(e){super(e),this.hasHighlight=()=>!0}destroy(){super.destroy(),this._boundsRenderer&&(this._boundsRenderer.destroy(),this._boundsRenderer=null)}enableRenderingBounds(e){this._boundsRenderer=new vs(e),this.requestRender()}get hasLabels(){return!1}onTileData(e,t){e.patch(t),this.contains(e)||this.addChild(e),this.requestRender()}onTileError(e){e.clear(),this.contains(e)||this.addChild(e)}_renderChildren(e,t){for(const s of this.children)s.isReady&&s.hasData&&(s.commit(e),e.context.setStencilFunction(At.EQUAL,s.stencilRef,255),s._displayList.replay(e,s,t))}}export{Us as o,Ps as t};