12 |
- (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-00dc3a48"],{"04c4":function(e,t,i){"use strict";i.d(t,"a",(function(){return h}));var s=i("c120"),r=i("ce76");const n=5e4,a={minX:0,minY:0,maxX:0,maxY:0};function o(e,t,i){a.minX=t[0],a.minY=t[1],a.maxX=t[2],a.maxY=t[3],e.search(a,i)}class h{constructor(){this._indexInvalid=!1,this._boundsToLoad=[],this._boundsById=new Map,this._idByBounds=new Map,this._index=new r["a"](9,Object(s["a"])("esri-csp-restrictions")?e=>({minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}):["[0]","[1]","[2]","[3]"]),this._loadIndex=()=>{if(this._indexInvalid){const e=new Array(this._idByBounds.size);let t=0;this._idByBounds.forEach((i,s)=>{e[t++]=s}),this._indexInvalid=!1,this._index.clear(),this._index.load(e)}else this._boundsToLoad.length&&(this._index.load(this._boundsToLoad.filter(e=>this._idByBounds.has(e))),this._boundsToLoad.length=0)}}clear(){this._indexInvalid=!1,this._boundsToLoad.length=0,this._boundsById.clear(),this._idByBounds.clear(),this._index.clear()}delete(e){const t=this._boundsById.get(e);this._boundsById.delete(e),t&&(this._idByBounds.delete(t),this._indexInvalid||this._index.remove(t))}forEachInBounds(e,t){this._loadIndex(),o(this._index,e,e=>t(this._idByBounds.get(e)))}get(e){return this._boundsById.get(e)}has(e){return this._boundsById.has(e)}invalidateIndex(){this._indexInvalid||(this._indexInvalid=!0,this._boundsToLoad.length=0)}set(e,t){if(!this._indexInvalid){const t=this._boundsById.get(e);t&&(this._index.remove(t),this._idByBounds.delete(t))}this._boundsById.set(e,t),t&&(this._idByBounds.set(t,e),this._indexInvalid||(this._boundsToLoad.push(t),this._boundsToLoad.length>n&&this._loadIndex()))}}},"461f":function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var s=i("b2b2"),r=i("d97e"),n=i("9392"),a=i("8152");const o={getObjectId:e=>e.objectId,getAttributes:e=>e.attributes,getAttribute:(e,t)=>e.attributes[t],cloneWithGeometry:(e,t)=>new n["a"](t,e.attributes,null,e.objectId),getGeometry:e=>e.geometry,getCentroid:(e,t)=>(Object(s["j"])(e.centroid)&&(e.centroid=Object(r["a"])(new a["a"],e.geometry,t.hasZ,t.hasM)),e.centroid)}},"615f":function(e,t,i){"use strict";i.r(t),i.d(t,"FeatureServiceSnappingSourceWorker",(function(){return ee})),i.d(t,"default",(function(){return te}));var s=i("a4ee"),r=i("ce6d"),n=i("af40"),a=i("b2b2"),o=i("f4cc"),h=i("3795"),c=i("59b2"),l=i("b50f"),u=(i("c120"),i("cea0"),i("d386")),d=i("5996"),f=i("6517"),p=i("6411"),g=i("dff3"),_=i("f806"),b=i("69dd"),m=i("fc29");let y=class extends m["a"]{constructor(){super(...arguments),this.updating=!1,this.pending=[]}push(e,t){this.pending.push({promise:e,callback:t}),1===this.pending.length&&this._process()}_process(){if(!this.pending.length)return void(this.updating=!1);this.updating=!0;const e=this.pending[0];e.promise.then(t=>e.callback(t)).catch(()=>{}).then(()=>{this.pending.shift(),this._process()})}};Object(s["a"])([Object(c["b"])()],y.prototype,"updating",void 0),y=Object(s["a"])([Object(u["a"])("esri.core.AsyncSequence")],y);var O,j=i("9096"),E=i("c649"),F=i("e92d"),v=i("477c"),x=i("3af1"),I=i("9180"),T=i("6655"),C=i("86e7"),S=i("e9fc"),w=i("792b");class B{constructor(e,t){this.data=e,this.resolution=t,this.state={type:O.CREATED},this.alive=!0}process(e){switch(this.state.type){case O.CREATED:return this.state=this._gotoFetchCount(this.state,e),this.state.task.promise.then(e.resume,e.resume);case O.FETCH_COUNT:break;case O.FETCHED_COUNT:return this.state=this._gotoFetchFeatures(this.state,e),this.state.task.promise.then(e.resume,e.resume);case O.FETCH_FEATURES:break;case O.FETCHED_FEATURES:this.state=this._goToDone(this.state,e);case O.DONE:}return null}get debugInfo(){return{data:this.data,featureCount:this.featureCount,state:this.stateToString}}get featureCount(){switch(this.state.type){case O.CREATED:case O.FETCH_COUNT:return 0;case O.FETCHED_COUNT:return this.state.featureCount;case O.FETCH_FEATURES:return this.state.previous.featureCount;case O.FETCHED_FEATURES:return this.state.features.length;case O.DONE:return this.state.previous.features.length}}get stateToString(){switch(this.state.type){case O.CREATED:return"created";case O.FETCH_COUNT:return"fetch-count";case O.FETCHED_COUNT:return"fetched-count";case O.FETCH_FEATURES:return"fetch-features";case O.FETCHED_FEATURES:return"fetched-features";case O.DONE:return"done"}}_gotoFetchCount(e,t){return{type:O.FETCH_COUNT,previous:e,task:Object(o["h"])(async e=>{const i=await Object(w["e"])(t.fetchCount(this,e));this.state.type===O.FETCH_COUNT&&(this.state=this._gotoFetchedCount(this.state,i.ok?i.value:1/0))})}}_gotoFetchedCount(e,t){return{type:O.FETCHED_COUNT,featureCount:t,previous:e}}_gotoFetchFeatures(e,t){return{type:O.FETCH_FEATURES,previous:e,task:Object(o["h"])(async i=>{const s=await Object(w["e"])(t.fetchFeatures(this,e.featureCount,i));this.state.type===O.FETCH_FEATURES&&(this.state=this._gotoFetchedFeatures(this.state,s.ok?s.value:[]))})}}_gotoFetchedFeatures(e,t){return{type:O.FETCHED_FEATURES,previous:e,features:t}}_goToDone(e,t){return t.finish(this,e.features),{type:O.DONE,previous:e}}reset(){const e=this.state;switch(this.state={type:O.CREATED},e.type){case O.CREATED:case O.FETCHED_COUNT:case O.FETCHED_FEATURES:case O.DONE:break;case O.FETCH_COUNT:case O.FETCH_FEATURES:e.task.abort()}}intersects(e){return!(!Object(a["j"])(e)&&this.data.extent)||(Object(I["s"])(e,M),Object(I["w"])(this.data.extent,M))}}!function(e){e[e.CREATED=0]="CREATED",e[e.FETCH_COUNT=1]="FETCH_COUNT",e[e.FETCHED_COUNT=2]="FETCHED_COUNT",e[e.FETCH_FEATURES=3]="FETCH_FEATURES",e[e.FETCHED_FEATURES=4]="FETCHED_FEATURES",e[e.DONE=5]="DONE"}(O||(O={}));const M=Object(I["l"])(),A=F["a"].getLogger("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher");let R=class extends j["a"]{constructor(e){super(e),this.tilesOfInterest=[],this.availability=0,this.pendingTiles=new Map,this.pendingEdits=new y,this.pendingEditsAbortController=new AbortController}get minimumVerticesPerFeature(){var e;switch(null==(e=this.store)?void 0:e.featureStore.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":return 1;case"esriGeometryPolygon":return 4;case"esriGeometryPolyline":return 2}}set filter(e){const t=this._get("filter"),i=this._filterProperties(e);JSON.stringify(t)!==JSON.stringify(i)&&this._set("filter",i)}set customParameters(e){const t=this._get("customParameters");JSON.stringify(t)!==JSON.stringify(e)&&this._set("customParameters",e)}get configuration(){return{filter:this.filter,customParameters:this.customParameters,tileInfo:this.tileInfo,tileSize:this.tileSize}}set tileInfo(e){const t=this._get("tileInfo");t!==e&&(Object(a["k"])(e)&&Object(a["k"])(t)&&JSON.stringify(e)===JSON.stringify(t)||(this._set("tileInfo",e),this.store.tileInfo=e))}set tileSize(e){this._get("tileSize")!==e&&this._set("tileSize",e)}get updating(){return this.updatingHandles.updating||this.pendingEdits.updating}initialize(){this._initializeFetchExtent(),this.updatingHandles.add(()=>this.configuration,()=>this.refresh()),this.updatingHandles.add(()=>this.tilesOfInterest,(e,t)=>{Object(l["e"])(e,t,({id:e},{id:t})=>e===t)||this._process()},v["c"])}destroy(){this.pendingTiles.forEach(e=>this._deletePendingTile(e)),this.pendingTiles.clear(),this.store.destroy(),this.tilesOfInterest.length=0,this.pendingEditsAbortController.abort(),this.pendingEditsAbortController=null}refresh(){this.store.refresh(),this.pendingTiles.forEach(e=>this._deletePendingTile(e)),this._process()}applyEdits(e){this.pendingEdits.push(e,async e=>{if(0===e.addedFeatures.length&&0===e.updatedFeatures.length&&0===e.deletedFeatures.length)return;for(const[,i]of this.pendingTiles)i.reset();const t={...e,deletedFeatures:e.deletedFeatures.map(({objectId:e,globalId:t})=>e&&-1!==e?e:this._lookupObjectIdByGlobalId(t))};await this.updatingHandles.addPromise(this.store.processEdits(t,(e,t)=>this._queryFeaturesById(e,t),this.pendingEditsAbortController.signal)),this._processPendingTiles()})}_initializeFetchExtent(){if(!this.capabilities.query.supportsExtent)return;const e=Object(o["h"])(async e=>{try{var t;const i=await Object(S["executeQueryForExtent"])(this.url,new b["a"]({where:"1=1",outSpatialReference:this.spatialReference,cacheHint:!!this.capabilities.query.supportsCacheHint||void 0}),{query:this.configuration.customParameters,signal:e});this.store.extent=x["a"].fromJSON(null==(t=i.data)?void 0:t.extent)}catch(i){Object(o["u"])(i),A.warn("Failed to fetch data extent",i)}});this.updatingHandles.addPromise(e.promise.then(()=>this._process())),this.handles.add(Object(E["b"])(()=>e.abort()))}get debugInfo(){return{numberOfFeatures:this.store.featureStore.numFeatures,tilesOfInterest:this.tilesOfInterest,pendingTiles:Array.from(this.pendingTiles.values()).map(e=>e.debugInfo),storedTiles:this.store.debugInfo}}_process(){this._markTilesNotAlive(),this._createPendingTiles(),this._deletePendingTiles(),this._processPendingTiles()}_markTilesNotAlive(){for(const[,e]of this.pendingTiles)e.alive=!1}_createPendingTiles(){const e=this._collectMissingTilesInfo();if(this._setAvailability(Object(a["j"])(e)?1:e.coveredArea/e.fullArea),!Object(a["j"])(e))for(const{data:t,resolution:i}of e.missingTiles){const e=this.pendingTiles.get(t.id);e?(e.resolution=i,e.alive=!0):this._createPendingTile(t,i)}}_collectMissingTilesInfo(){let e=null;for(let t=this.tilesOfInterest.length-1;t>=0;t--){const i=this.tilesOfInterest[t],s=this.store.process(i,(e,t)=>this._verifyTileComplexity(e,t));Object(a["j"])(e)?e=s:e.prepend(s)}return e}_deletePendingTiles(){for(const[,e]of this.pendingTiles)e.alive||this._deletePendingTile(e)}_processPendingTiles(){const e={fetchCount:(e,t)=>this._fetchCount(e,t),fetchFeatures:(e,t,i)=>this._fetchFeatures(e,t,i),finish:(e,t)=>this._finishPendingTile(e,t),resume:()=>this._processPendingTiles()};if(this._ensureFetchAllCounts(e))for(const[,t]of this.pendingTiles)this._verifyTileComplexity(this.store.getFeatureCount(t.data),t.resolution)&&this.updatingHandles.addPromise(t.process(e))}_verifyTileComplexity(e,t){return this._verifyVertexComplexity(e)&&this._verifyFeatureDensity(e,t)}_verifyVertexComplexity(e){return e*this.minimumVerticesPerFeature<H}_verifyFeatureDensity(e,t){if(Object(a["j"])(this.tileInfo))return!1;const i=this.tileSize*t;return e*(k/(i*i))<N}_ensureFetchAllCounts(e){let t=!0;for(const[,i]of this.pendingTiles)i.state.type<O.FETCHED_COUNT&&this.updatingHandles.addPromise(i.process(e)),i.state.type<=O.FETCH_COUNT&&(t=!1);return t}_finishPendingTile(e,t){this.store.add(e.data,t),this._deletePendingTile(e),this._updateAvailability()}_updateAvailability(){const e=this._collectMissingTilesInfo();this._setAvailability(Object(a["j"])(e)?1:e.coveredArea/e.fullArea)}_setAvailability(e){this._set("availability",e)}_createPendingTile(e,t){const i=new B(e,t);return this.pendingTiles.set(e.id,i),i}_deletePendingTile(e){e.reset(),this.pendingTiles.delete(e.data.id)}async _fetchCount(e,t){return this.store.fetchCount(e.data,this.url,this._createCountQuery(e),{query:this.customParameters,timeout:D,signal:t})}async _fetchFeatures(e,t,i){let s,r=0,n=0,o=t;for(;;){const h=this._createFeaturesQuery(e),c=this._setPagingParameters(h,r,o),{features:l,exceededTransferLimit:u}=await this._queryFeatures(h,i);if(c&&(r+=Object(a["t"])(h.num)),n+=l.length,s=s?s.concat(l):l,o=t-n,!c||!u||o<=0)return s}}_filterProperties(e){return Object(a["j"])(e)?{where:"1=1",gdbVersion:void 0,timeExtent:void 0}:{where:e.where||"1=1",timeExtent:e.timeExtent,gdbVersion:e.gdbVersion}}_lookupObjectIdByGlobalId(e){const t=this.globalIdField,i=this.objectIdField;if(Object(a["j"])(t))throw new Error("Expected globalIdField to be defined");let s=null;if(this.store.featureStore.forEach(r=>{var n;e===r.attributes[t]&&(s=null!=(n=r.objectId)?n:r.attributes[i])}),Object(a["j"])(s))throw new Error("Expected to find a feature with globalId "+e);return s}_queryFeaturesById(e,t){const i=this._createFeaturesQuery(null);return i.objectIds=e,this._queryFeatures(i,t)}_queryFeatures(e,t){return this.capabilities.query.supportsFormatPBF?this._queryFeaturesPBF(e,t):this._queryFeaturesJSON(e,t)}async _queryFeaturesPBF(e,t){const{sourceSpatialReference:i}=this,{data:s}=await Object(S["executeQueryPBF"])(this.url,e,new C["b"]({sourceSpatialReference:i}),{query:this.configuration.customParameters,timeout:D,signal:t});return Object(T["z"])(s)}async _queryFeaturesJSON(e,t){const{sourceSpatialReference:i}=this,{data:s}=await Object(S["executeQuery"])(this.url,e,i,{query:this.configuration.customParameters,timeout:D,signal:t});return Object(T["b"])(s,this.objectIdField)}_createCountQuery(e){const t=this._createBaseQuery(e);return this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}_createFeaturesQuery(e){const t=this._createBaseQuery(e);return t.outFields=this.globalIdField?[this.globalIdField,this.objectIdField]:[this.objectIdField],t.returnGeometry=!0,Object(a["k"])(e)&&(this.capabilities.query.supportsResultType?t.resultType="tile":this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0)),t}_createBaseQuery(e){const t=new b["a"]({returnZ:!1,returnM:!1,geometry:Object(a["k"])(this.tileInfo)&&Object(a["k"])(e)?Object(I["B"])(e.data.extent,this.tileInfo.spatialReference):void 0}),i=this.configuration.filter;return Object(a["k"])(i)&&(t.where=i.where,t.gdbVersion=i.gdbVersion,t.timeExtent=i.timeExtent),t.outSpatialReference=this.spatialReference,t}_setPagingParameters(e,t,i){if(!this.capabilities.query.supportsPagination)return!1;const{supportsMaxRecordCountFactor:s,supportsCacheHint:r,tileMaxRecordCount:n,maxRecordCount:a,supportsResultType:o}=this.capabilities.query,h=s?b["a"].MAX_MAX_RECORD_COUNT_FACTOR:1,c=h*((o||r)&&n?n:a||P);return e.start=t,s?(e.maxRecordCountFactor=Math.min(h,Math.ceil(i/c)),e.num=Math.min(i,e.maxRecordCountFactor*c)):e.num=Math.min(i,c),!0}};Object(s["a"])([Object(c["b"])({constructOnly:!0})],R.prototype,"url",void 0),Object(s["a"])([Object(c["b"])({constructOnly:!0})],R.prototype,"objectIdField",void 0),Object(s["a"])([Object(c["b"])({constructOnly:!0})],R.prototype,"globalIdField",void 0),Object(s["a"])([Object(c["b"])({constructOnly:!0})],R.prototype,"capabilities",void 0),Object(s["a"])([Object(c["b"])({constructOnly:!0})],R.prototype,"sourceSpatialReference",void 0),Object(s["a"])([Object(c["b"])({constructOnly:!0})],R.prototype,"spatialReference",void 0),Object(s["a"])([Object(c["b"])({constructOnly:!0})],R.prototype,"store",void 0),Object(s["a"])([Object(c["b"])({readOnly:!0})],R.prototype,"minimumVerticesPerFeature",null),Object(s["a"])([Object(c["b"])()],R.prototype,"filter",null),Object(s["a"])([Object(c["b"])()],R.prototype,"customParameters",null),Object(s["a"])([Object(c["b"])({readOnly:!0})],R.prototype,"configuration",null),Object(s["a"])([Object(c["b"])()],R.prototype,"tileInfo",null),Object(s["a"])([Object(c["b"])()],R.prototype,"tileSize",null),Object(s["a"])([Object(c["b"])()],R.prototype,"tilesOfInterest",void 0),Object(s["a"])([Object(c["b"])({readOnly:!0})],R.prototype,"updating",null),Object(s["a"])([Object(c["b"])({readOnly:!0})],R.prototype,"availability",void 0),R=Object(s["a"])([Object(u["a"])("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")],R);const P=2e3,D=6e5,H=1e6,k=25,N=1;var X=i("f0b9"),Y=i("04c4");class U{constructor(){this._store=new Map,this._byteSize=0}set(e,t){this.delete(e),this._store.set(e,t),this._byteSize+=t.byteSize}delete(e){const t=this._store.get(e);return!!this._store.delete(e)&&(this._byteSize-=t.byteSize,!0)}get(e){return this._used(e),this._store.get(e)}has(e){return this._used(e),this._store.has(e)}clear(){this._store.clear()}applyByteSizeLimit(e,t){for(const[i,s]of this._store){if(this._byteSize<=e)break;this.delete(i),t(s)}}values(){return this._store.values()}[Symbol.iterator](){return this._store[Symbol.iterator]()}_used(e){const t=this._store.get(e);t&&(this._store.delete(e),this._store.set(e,t))}}let z=class extends m["a"]{constructor(e){super(e),this.tileInfo=null,this.extent=null,this.maximumByteSize=10*X["a"].MEGABYTES,this.tileBounds=new Y["a"],this.tiles=new U,this.refCounts=new Map,this.tileFeatureCounts=new Map,this.tmpBoundingRect=Object(I["l"])()}add(e,t){const i=[];for(const s of t)this._referenceFeature(s.objectId)===$.ADDED&&i.push(s);this._addTileStorage(e,new Set(t.map(({objectId:e})=>e)),q(t)),this.featureStore.addMany(i),this.tiles.applyByteSizeLimit(this.maximumByteSize,e=>this._removeTileStorage(e))}destroy(){this.clear(),this.tileFeatureCounts.clear()}clear(){this.featureStore.clear(),this.tileBounds.clear(),this.tiles.clear(),this.refCounts.clear()}refresh(){this.clear(),this.tileFeatureCounts.clear()}processEdits(e,t,i){return this._processEditsDelete(e.deletedFeatures.concat(e.updatedFeatures)),this._processEditsRefetch(e.addedFeatures.concat(e.updatedFeatures),t,i)}_addTileStorage(e,t,i){this.tiles.set(e.id,new G(e,t,i)),this.tileBounds.set(e.id,e.extent),this.tileFeatureCounts.set(e.id,t.size)}_remove({id:e}){const t=this.tiles.get(e);t&&this._removeTileStorage(t)}_removeTileStorage(e){const t=[];for(const s of e.objectIds)this._unreferenceFeature(s)===$.REMOVED&&t.push(s);this.featureStore.removeManyById(t);const i=e.data.id;this.tiles.delete(i),this.tileBounds.delete(i)}_processEditsDelete(e){this.featureStore.removeManyById(e);for(const[,t]of this.tiles){for(const i of e)t.objectIds.delete(i);this.tileFeatureCounts.set(t.data.id,t.objectIds.size)}for(const t of e)this.refCounts.delete(t)}async _processEditsRefetch(e,t,i){const s=(await t(e,i)).features,{hasZ:r,hasM:n}=this.featureStore;for(const o of s){const e=Object(T["s"])(this.tmpBoundingRect,o.geometry,r,n);Object(a["j"])(e)||this.tileBounds.forEachInBounds(e,e=>{const t=this.tiles.get(e);this.featureStore.add(o),t.objectIds.has(o.objectId)||(t.objectIds.add(o.objectId),this._referenceFeature(o.objectId),this.tileFeatureCounts.set(t.data.id,t.objectIds.size))})}}process(e,t=(()=>!0)){if(Object(a["j"])(this.tileInfo)||!e.extent||Object(a["k"])(this.extent)&&!Object(I["w"])(Object(I["s"])(this.extent,this.tmpBoundingRect),e.extent))return new Q(e);if(this.tiles.has(e.id))return new Q(e);const i=this._createTileTree(e,this.tileInfo);return this._simplify(i,t,null,0,1),this._collectMissingTiles(e,i,this.tileInfo)}get debugInfo(){return Array.from(this.tiles.values()).map(({data:e})=>({data:e,featureCount:this.tileFeatureCounts.get(e.id)||0}))}getFeatureCount(e){const t=this.tileFeatureCounts.get(e.id);return null!=t?t:0}async fetchCount(e,t,i,s){const r=this.tileFeatureCounts.get(e.id);if(null!=r)return r;const n=await Object(S["executeQueryForCount"])(t,i,s);return this.tileFeatureCounts.set(e.id,n.data.count),n.data.count}_createTileTree(e,t){const i=new V(e.level,e.row,e.col);return t.updateTileInfo(i,g["a"].ExtrapolateOptions.POWER_OF_TWO),this.tileBounds.forEachInBounds(e.extent,s=>{const r=this.tiles.get(s).data;this._tilesAreRelated(e,r)&&this._populateChildren(i,r,t,this.tileFeatureCounts.get(r.id)||0)}),i}_tilesAreRelated(e,t){if(!e||!t)return!1;if(e.level===t.level)return e.row===t.row&&e.col===t.col;const i=e.level<t.level,s=i?e:t,r=i?t:e,n=1<<r.level-s.level;return Math.floor(r.row/n)===s.row&&Math.floor(r.col/n)===s.col}_populateChildren(e,t,i,s){const r=t.level-e.level-1;if(r<0)return void(e.isLeaf=!0);const n=t.row>>r,o=t.col>>r,h=e.row<<1,c=o-(e.col<<1)+(n-h<<1),l=e.children[c];if(Object(a["k"])(l))this._populateChildren(l,t,i,s);else{const r=new V(e.level+1,n,o);i.updateTileInfo(r,g["a"].ExtrapolateOptions.POWER_OF_TWO),e.children[c]=r,this._populateChildren(r,t,i,s)}}_simplify(e,t,i,s,r){const n=r*r;if(e.isLeaf)return t(this.getFeatureCount(e),r)?0:(this._remove(e),Object(a["k"])(i)&&(i.children[s]=null),n);const o=r/2,h=o*o;let c=0;for(let l=0;l<e.children.length;l++){const i=e.children[l];c+=Object(a["k"])(i)?this._simplify(i,t,e,l,o):h}return 0===c?this._mergeChildren(e):1-c/n<Z&&(this._purge(e),Object(a["k"])(i)&&(i.children[s]=null),c=n),c}_mergeChildren(e){const t=new Set;let i=0;this._forEachLeaf(e,e=>{const s=this.tiles.get(e.id);if(s){i+=s.byteSize;for(const e of s.objectIds)t.has(e)||(t.add(e),this._referenceFeature(e));this._remove(e)}}),this._addTileStorage(e,t,i),e.isLeaf=!0,e.children[0]=e.children[1]=e.children[2]=e.children[3]=null,this.tileFeatureCounts.set(e.id,t.size)}_forEachLeaf(e,t){for(const i of e.children)Object(a["j"])(i)||(i.isLeaf?t(i):this._forEachLeaf(i,t))}_purge(e){if(!Object(a["j"])(e))if(e.isLeaf)this._remove(e);else for(let t=0;t<e.children.length;t++){const i=e.children[t];this._purge(i),e.children[t]=null}}_collectMissingTiles(e,t,i){const s=new W(i,e,this.extent);return this._collectMissingTilesRecurse(t,s,1),s.info}_collectMissingTilesRecurse(e,t,i){if(e.isLeaf)return;if(!e.hasChildren)return void t.addMissing(e.level,e.row,e.col,i);const s=i/2;for(let r=0;r<e.children.length;r++){const i=e.children[r];Object(a["j"])(i)?t.addMissing(e.level+1,(e.row<<1)+((2&r)>>1),(e.col<<1)+(1&r),s):this._collectMissingTilesRecurse(i,t,s)}}_referenceFeature(e){const t=(this.refCounts.get(e)||0)+1;return this.refCounts.set(e,t),1===t?$.ADDED:$.UNCHANGED}_unreferenceFeature(e){const t=(this.refCounts.get(e)||0)-1;return 0===t?(this.refCounts.delete(e),$.REMOVED):(t>0&&this.refCounts.set(e,t),$.UNCHANGED)}get test(){return{tiles:Array.from(this.tiles.values()).map(e=>`${e.data.id}:[${Array.from(e.objectIds)}]`),featureReferences:Array.from(this.refCounts.keys()).map(e=>`${e}:${this.refCounts.get(e)}`)}}};function q(e){return e.reduce((e,t)=>e+L(t),0)}function L(e){return 32+J(e.geometry)+Object(X["b"])(e.attributes)}function J(e){if(Object(a["j"])(e))return 0;const t=Object(X["c"])(e.lengths,4);return 32+Object(X["c"])(e.coords,8)+t}Object(s["a"])([Object(c["b"])({constructOnly:!0})],z.prototype,"featureStore",void 0),Object(s["a"])([Object(c["b"])()],z.prototype,"tileInfo",void 0),Object(s["a"])([Object(c["b"])()],z.prototype,"extent",void 0),Object(s["a"])([Object(c["b"])()],z.prototype,"maximumByteSize",void 0),z=Object(s["a"])([Object(u["a"])("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTileStore")],z);class G{constructor(e,t,i){this.data=e,this.objectIds=t,this.byteSize=i}}class V{constructor(e,t,i){this.level=e,this.row=t,this.col=i,this.isLeaf=!1,this.extent=null,this.children=[null,null,null,null]}get hasChildren(){return!this.isLeaf&&(Object(a["k"])(this.children[0])||Object(a["k"])(this.children[1])||Object(a["k"])(this.children[2])||Object(a["k"])(this.children[3]))}}class Q{constructor(e,t=[]){this.missingTiles=t,this.fullArea=0,this.coveredArea=0,this.fullArea=Object(I["d"])(e.extent),this.coveredArea=this.fullArea}prepend(e){this.missingTiles=e.missingTiles.concat(this.missingTiles),this.coveredArea+=e.coveredArea,this.fullArea+=e.fullArea}}class W{constructor(e,t,i){this.tileInfo=e,this.extent=null,this.info=new Q(t),Object(a["k"])(i)&&(this.extent=Object(I["s"])(i))}addMissing(e,t,i,s){const r={id:null,level:e,row:t,col:i};this.tileInfo.updateTileInfo(r,g["a"].ExtrapolateOptions.POWER_OF_TWO),!Object(a["k"])(r.extent)||Object(a["k"])(this.extent)&&!Object(I["w"])(this.extent,r.extent)||(this.info.missingTiles.push({data:r,resolution:s}),this.info.coveredArea-=Object(I["d"])(r.extent))}}const Z=.18751;var $;!function(e){e[e.ADDED=0]="ADDED",e[e.REMOVED=1]="REMOVED",e[e.UNCHANGED=2]="UNCHANGED"}($||($={}));var K=i("d347");let ee=class extends r["a"].EventedAccessor{constructor(){super(...arguments),this.isInitializing=!0,this.whenSetup=Object(o["f"])(),this.handles=new n["a"],this.updatingHandles=new K["a"],this.pendingApplyEdits=new Map}get updating(){return this.featureFetcher.updating||this.isInitializing||this.updatingHandles.updating}destroy(){this.featureFetcher.destroy(),this.queryEngine.destroy(),this.featureStore.clear(),this.handles.destroy()}async setup(e){const{geometryType:t,objectIdField:i,timeInfo:s,fields:r}=e.serviceInfo;return this.featureStore=new f["a"]({...e.serviceInfo,hasZ:!1,hasM:!1}),this.queryEngine=new p["a"]({spatialReference:e.spatialReference,featureStore:this.featureStore,geometryType:t,fields:r,hasZ:!1,hasM:!1,objectIdField:i,timeInfo:s?_["a"].fromJSON(s):null}),this.featureFetcher=new R({store:new z({featureStore:this.featureStore}),url:e.serviceInfo.url,objectIdField:e.serviceInfo.objectIdField,globalIdField:e.serviceInfo.globalIdField,capabilities:e.serviceInfo.capabilities,spatialReference:d["a"].fromJSON(e.spatialReference),sourceSpatialReference:d["a"].fromJSON(e.serviceInfo.spatialReference)}),this.handles.add([this.featureFetcher.watch("availability",e=>this.emit("notify-availability",{availability:e}),!0),this.watch("updating",()=>this._notifyUpdating())]),this.whenSetup.resolve(),this.isInitializing=!1,this.configure(e.configuration)}async configure(e){return await this.updatingHandles.addPromise(this.whenSetup.promise),this._updateFeatureFetcherConfiguration(e),{result:{}}}async fetchCandidates(e,t){return await this.whenSetup.promise,Object(o["v"])(t),{result:await this.queryEngine.executeQueryForSnapping({point:e.point,distance:e.distance,types:e.types,query:Object(a["k"])(e.filter)?e.filter:{where:"1=1"}},Object(a["k"])(t)?t.signal:null)}}async updateTiles(e,t){return await this.updatingHandles.addPromise(this.whenSetup.promise),Object(o["v"])(t),this.featureFetcher.tileSize=e.tileSize,this.featureFetcher.tilesOfInterest=e.tiles,this.featureFetcher.tileInfo=Object(a["k"])(e.tileInfo)?g["a"].fromJSON(e.tileInfo):null,{result:{}}}async refresh(e,t){return await this.updatingHandles.addPromise(this.whenSetup.promise),Object(o["v"])(t),this.featureFetcher.refresh(),{result:{}}}async whenNotUpdating(e,t){return await this.updatingHandles.addPromise(this.whenSetup.promise),Object(o["v"])(t),await Object(o["z"])(Object(h["i"])(this,"updating"),t),{result:{}}}async getDebugInfo(e,t){return Object(o["v"])(t),{result:this.featureFetcher.debugInfo}}async beginApplyEdits(e,t){this.updatingHandles.addPromise(this.whenSetup.promise),Object(o["v"])(t);const i=Object(o["f"])();return this.pendingApplyEdits.set(e.id,i),this.featureFetcher.applyEdits(i.promise),this.updatingHandles.addPromise(i.promise),{result:{}}}async endApplyEdits(e,t){const i=this.pendingApplyEdits.get(e.id);return i&&i.resolve(e.edits),Object(o["v"])(t),{result:{}}}_updateFeatureFetcherConfiguration(e){this.featureFetcher.filter=Object(a["k"])(e.filter)?b["a"].fromJSON(e.filter):null,this.featureFetcher.customParameters=e.customParameters}_notifyUpdating(){this.emit("notify-updating",{updating:this.updating})}};function te(){return new ee}Object(s["a"])([Object(c["b"])({readOnly:!0})],ee.prototype,"updating",null),Object(s["a"])([Object(c["b"])()],ee.prototype,"isInitializing",void 0),ee=Object(s["a"])([Object(u["a"])("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceSnappingSourceWorker")],ee)},6517:function(e,t,i){"use strict";i.d(t,"a",(function(){return d}));var s=i("ce50"),r=i("ce6d"),n=i("e92d"),a=i("b2b2"),o=i("4261"),h=i("9180"),c=i("6655"),l=i("04c4"),u=i("461f");class d{constructor(e){this.geometryInfo=e,this._boundsStore=new l["a"],this._featuresById=new Map,this._markedIds=new Set,this.events=new r["a"],this.featureAdapter=u["a"]}get geometryType(){return this.geometryInfo.geometryType}get hasM(){return this.geometryInfo.hasM}get hasZ(){return this.geometryInfo.hasZ}get numFeatures(){return this._featuresById.size}get fullBounds(){if(!this.numFeatures)return null;const e=Object(h["l"])(h["a"]);return this._featuresById.forEach(t=>{const i=this._boundsStore.get(t.objectId);i&&(e[0]=Math.min(i[0],e[0]),e[1]=Math.min(i[1],e[1]),e[2]=Math.max(i[2],e[2]),e[3]=Math.max(i[3],e[3]))}),e}get storeStatistics(){let e=0;return this._featuresById.forEach(t=>{Object(a["k"])(t.geometry)&&t.geometry.coords&&(e+=t.geometry.coords.length)}),{featureCount:this._featuresById.size,vertexCount:e/(this.hasZ?this.hasM?4:3:this.hasM?3:2)}}add(e){this._add(e),this._emitChanged()}addMany(e){for(const t of e)this._add(t);this._emitChanged()}clear(){this._featuresById.clear(),this._boundsStore.clear(),this._emitChanged()}removeById(e){const t=this._featuresById.get(e);return t?(this._remove(t),this._emitChanged(),t):null}removeManyById(e){this._boundsStore.invalidateIndex();for(const t of e){const e=this._featuresById.get(t);e&&this._remove(e)}this._emitChanged()}forEachBounds(e,t,i){for(const s of e){const e=this._boundsStore.get(s.objectId);e&&t(Object(o["s"])(i,e))}}getFeature(e){return this._featuresById.get(e)}has(e){return this._featuresById.has(e)}forEach(e){this._featuresById.forEach(t=>e(t))}forEachInBounds(e,t){this._boundsStore.forEachInBounds(e,e=>{t(this._featuresById.get(e))})}startMarkingUsedFeatures(){this._boundsStore.invalidateIndex(),this._markedIds.clear()}sweep(){let e=!1;this._featuresById.forEach((t,i)=>{this._markedIds.has(i)||(e=!0,this._remove(t))}),this._markedIds.clear(),e&&this._emitChanged()}_emitChanged(){this.events.emit("changed",void 0)}_add(e){if(!e)return;const t=e.objectId;if(null==t)return void n["a"].getLogger("esri.layers.graphics.data.FeatureStore").error(new s["a"]("featurestore:invalid-feature","feature id is missing",{feature:e}));const i=this._featuresById.get(t);let r;if(this._markedIds.add(t),i?(e.displayId=i.displayId,r=this._boundsStore.get(t),this._boundsStore.delete(t)):Object(a["k"])(this.onFeatureAdd)&&this.onFeatureAdd(e),Object(a["j"])(e.geometry)||!e.geometry.coords||!e.geometry.coords.length)return this._boundsStore.set(t,null),void this._featuresById.set(t,e);r=Object(c["s"])(Object(a["k"])(r)?r:Object(h["l"])(),e.geometry,this.geometryInfo.hasZ,this.geometryInfo.hasM),Object(a["k"])(r)&&this._boundsStore.set(t,r),this._featuresById.set(t,e)}_remove(e){return Object(a["k"])(this.onFeatureRemove)&&this.onFeatureRemove(e),this._markedIds.delete(e.objectId),this._boundsStore.delete(e.objectId),this._featuresById.delete(e.objectId),e}}},ce76:function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var s=i("b50f"),r=i("b2b2"),n=i("8a44"),a=i("4637");class o{constructor(e=9,t){this.compareMinX=u,this.compareMinY=d,this._toBBox=function(e){return e},this._maxEntries=Math.max(4,e||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),t&&("function"==typeof t?this._toBBox=t:this._initFormat(t)),this.clear()}destroy(){this.clear(),O.prune(),j.prune(),E.prune(),F.prune()}all(e){this._all(this.data,e)}search(e,t){let i=this.data;const s=this._toBBox;if(m(e,i))for(O.clear();i;){for(let r=0,n=i.children.length;r<n;r++){const n=i.children[r],a=i.leaf?s(n):n;m(e,a)&&(i.leaf?t(n):b(e,a)?this._all(n,t):O.push(n))}i=O.pop()}}collides(e){let t=this.data;const i=this._toBBox;if(!m(e,t))return!1;for(O.clear();t;){for(let s=0,r=t.children.length;s<r;s++){const r=t.children[s],n=t.leaf?i(r):r;if(m(e,n)){if(t.leaf||b(e,n))return!0;O.push(r)}}t=O.pop()}return!1}load(e){if(!e.length)return this;if(e.length<this._minEntries){for(let t=0,i=e.length;t<i;t++)this.insert(e[t]);return this}let t=this._build(e.slice(0,e.length),0,e.length-1,0);if(this.data.children.length)if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){const e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}else this.data=t;return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=new I([]),this}remove(e){if(!e)return this;let t,i=this.data,n=null,a=0,o=!1;const h=this._toBBox(e);for(E.clear(),F.clear();i||E.length>0;){var c;if(i||(i=Object(r["c"])(E.pop()),n=E.data[E.length-1],a=null!=(c=F.pop())?c:0,o=!0),i.leaf&&(t=Object(s["g"])(i.children,e,i.children.length,i.indexHint),-1!==t))return i.children.splice(t,1),E.push(i),this._condense(E),this;o||i.leaf||!b(i,h)?n?(a++,i=n.children[a],o=!1):i=null:(E.push(i),F.push(a),a=0,n=i,i=i.children[0])}return this}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){let i=e;for(j.clear();i;){var s;if(!0===i.leaf)for(const e of i.children)t(e);else j.pushArray(i.children);i=null!=(s=j.pop())?s:null}}_build(e,t,i,s){const r=i-t+1;let n=this._maxEntries;if(r<=n){const s=new I(e.slice(t,i+1));return h(s,this._toBBox),s}s||(s=Math.ceil(Math.log(r)/Math.log(n)),n=Math.ceil(r/n**(s-1)));const a=new T([]);a.height=s;const o=Math.ceil(r/n),c=o*Math.ceil(Math.sqrt(n));y(e,t,i,c,this.compareMinX);for(let h=t;h<=i;h+=c){const t=Math.min(h+c-1,i);y(e,h,t,o,this.compareMinY);for(let i=h;i<=t;i+=o){const r=Math.min(i+o-1,t);a.children.push(this._build(e,i,r,s-1))}}return h(a,this._toBBox),a}_chooseSubtree(e,t,i,s){for(;s.push(t),!0!==t.leaf&&s.length-1!==i;){let i,s=1/0,r=1/0;for(let n=0,a=t.children.length;n<a;n++){const a=t.children[n],o=f(a),h=g(e,a)-o;h<r?(r=h,s=o<s?o:s,i=a):h===r&&o<s&&(s=o,i=a)}t=i||t.children[0]}return t}_insert(e,t,i){const s=this._toBBox,r=i?e:s(e);E.clear();const n=this._chooseSubtree(r,this.data,t,E);for(n.children.push(e),l(n,r);t>=0&&E.data[t].children.length>this._maxEntries;)this._split(E,t),t--;this._adjustParentBBoxes(r,E,t)}_split(e,t){const i=e.data[t],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const n=this._chooseSplitIndex(i,r,s);if(!n)return void console.log(" Error: assertion failed at PooledRBush._split: no valid split index");const a=i.children.splice(n,i.children.length-n),o=i.leaf?new I(a):new T(a);o.height=i.height,h(i,this._toBBox),h(o,this._toBBox),t?e.data[t-1].children.push(o):this._splitRoot(i,o)}_splitRoot(e,t){this.data=new T([e,t]),this.data.height=e.height+1,h(this.data,this._toBBox)}_chooseSplitIndex(e,t,i){let s,r,n;s=r=1/0;for(let a=t;a<=i-t;a++){const t=c(e,0,a,this._toBBox),o=c(e,a,i,this._toBBox),h=_(t,o),l=f(t)+f(o);h<s?(s=h,n=a,r=l<r?l:r):h===s&&l<r&&(r=l,n=a)}return n}_chooseSplitAxis(e,t,i){const s=e.leaf?this.compareMinX:u,r=e.leaf?this.compareMinY:d;this._allDistMargin(e,t,i,s)<this._allDistMargin(e,t,i,r)&&e.children.sort(s)}_allDistMargin(e,t,i,s){e.children.sort(s);const r=this._toBBox,n=c(e,0,t,r),a=c(e,i-t,i,r);let o=p(n)+p(a);for(let h=t;h<i-t;h++){const t=e.children[h];l(n,e.leaf?r(t):t),o+=p(n)}for(let h=i-t-1;h>=t;h--){const t=e.children[h];l(a,e.leaf?r(t):t),o+=p(a)}return o}_adjustParentBBoxes(e,t,i){for(let s=i;s>=0;s--)l(t.data[s],e)}_condense(e){for(let t=e.length-1;t>=0;t--){const i=e.data[t];if(0===i.children.length)if(t>0){const r=e.data[t-1],n=r.children;n.splice(Object(s["g"])(n,i,n.length,r.indexHint),1)}else this.clear();else h(i,this._toBBox)}}_initFormat(e){const t=["return a"," - b",";"];this.compareMinX=new Function("a","b",t.join(e[0])),this.compareMinY=new Function("a","b",t.join(e[1])),this._toBBox=new Function("a","return {minX: a"+e[0]+", minY: a"+e[1]+", maxX: a"+e[2]+", maxY: a"+e[3]+"};")}}function h(e,t){c(e,0,e.children.length,t,e)}function c(e,t,i,s,r){r||(r=new I([])),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let n,a=t;a<i;a++)n=e.children[a],l(r,e.leaf?s(n):n);return r}function l(e,t){e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY)}function u(e,t){return e.minX-t.minX}function d(e,t){return e.minY-t.minY}function f(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function p(e){return e.maxX-e.minX+(e.maxY-e.minY)}function g(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function _(e,t){const i=Math.max(e.minX,t.minX),s=Math.max(e.minY,t.minY),r=Math.min(e.maxX,t.maxX),n=Math.min(e.maxY,t.maxY);return Math.max(0,r-i)*Math.max(0,n-s)}function b(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function m(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function y(e,t,i,s,n){const o=[t,i];for(;o.length;){const t=Object(r["c"])(o.pop()),i=Object(r["c"])(o.pop());if(t-i<=s)continue;const h=i+Math.ceil((t-i)/s/2)*s;Object(a["a"])(e,h,i,t,n),o.push(i,h,h,t)}}const O=new n["a"],j=new n["a"],E=new n["a"],F=new n["a"]({deallocator:void 0});class v{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}}class x extends v{constructor(){super(...arguments),this.height=1,this.indexHint=new s["a"]}}class I extends x{constructor(e){super(),this.children=e,this.leaf=!0}}class T extends x{constructor(e){super(),this.children=e,this.leaf=!1}}}}]);
- //# sourceMappingURL=chunk-00dc3a48.05df803b.js.map
|