text: // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  // See https://js.arcgis.com/4.11/esri/copyright.txt for details.
  //>>built
  define("require exports ../../../core/tsSupport/declareExtendsHelper ../../../core/tsSupport/decorateHelper ../../../core/tsSupport/generatorHelper ../../../core/tsSupport/awaiterHelper @dojo/framework/shim/array @dojo/framework/shim/Set ../../../Graphic ../../../core/arrayUtils ../../../core/has ../../../core/Logger ../../../core/PooledArray ../../../core/promiseUtils ../../../core/watchUtils ../../../core/accessorSupport/decorators ../../../core/libs/gl-matrix-2/vec3f64 ../../../core/libs/rbush/PooledRBush ../../../geometry/support/aaBoundingBox ../../../geometry/support/aaBoundingRect ../../../geometry/support/contains ../../../layers/graphics/dehydratedFeatures ../../../layers/graphics/controllers/I3SOnDemandController ../../../layers/support/fieldUtils ../../../renderers/support/renderingInfoUtils ./LayerView3D ./graphics/Graphics3DFeatureLikeLayerView ./graphics/Graphics3DVerticalScale ./i3s/I3SQueryEngine ./i3s/I3SUtil ./support/DefinitionExpressionSceneLayerView ./support/layerViewUpdatingProperties ./support/PopupSceneLayerView ../support/GraphicsMap ../support/orientedBoundingBox ../support/projectionUtils ../../layers/support/FeatureFilter".split(" "),
  function(n,pa,S,h,L,M,J,N,T,O,U,V,W,H,t,f,X,Y,u,P,Z,A,aa,Q,ba,ca,da,ea,fa,y,ga,ha,ia,ja,ka,E,la){function R(f,b){for(var a=0;a<f.length;a++)for(var c=0,m=f[a].graphics;c<m.length;c++){var e=m[c];e.attributes||(e.attributes={});if(b.loadedAttributes)for(var d=0,F=b.loadedAttributes;d<F.length;d++){var k=F[d].name;b.attributeData[k]&&(e.attributes[k]=y.getCachedAttributeValue(b.attributeData[k],a))}}}var G=V.getLogger("esri.views.3d.layers.SceneLayerGraphicsView3D");n=function(n){function b(a){a=n.call(this)||
  this;a._nodesAddedToStage=new Map;a.overlayUpdating=!1;a.supportsDraping=!0;a._queryEngine=null;a._memCache=null;a.loadedGraphics=new ja.GraphicsMap;a.progressiveLoadFactor=1;a.supportsHeightUnitConversion=!0;a._coordinatesOutsideExtentErrors=0;a._maxCoordinatesOutsideExtentErrors=20;return a}S(b,n);b.prototype.initialize=function(){var a=this;y.checkSpatialReferences(this.layer,this.view.spatialReference,this.view.viewingMode);this.handles.add([t.init(this,["layer.renderer","layer.labelingInfo",
  "layer.labelsVisible","definitionExpressionFields"],function(){return a._updateRequiredFields()}),t.init(this.layer,"rangeInfos",function(c){return a._rangeInfosChanged(c)}),this.layer.watch("renderer",function(c,b){return a._rendererChange(c,b)}),this.watch(["layer.objectIdFilter","parsedDefinitionExpression"],function(){return a._filterChange()})]);this._set("graphics3d",new da({owner:this,layer:this.layer,asyncGraphicsUpdates:!0,scaleVisibilityEnabled:!1,filterVisibilityEnabled:!0,frustumVisibilityEnabled:!1,
  elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,suspendResumeExtentMode:"data",dataExtent:this.layer.fullExtent,updateClippingExtent:function(c){return a._updateClippingExtent(c)},queryGraphicUIDsInExtent:function(c,b,e){return a._queryGraphicUIDsInExtent(c,b,e)}}));this.supportsHeightUnitConversion&&(this._verticalScale=new ea({sourceSpatialReference:this.layer.spatialReference,destSpatialReference:this.view.spatialReference}));this.addResolvingPromise(this.graphics3d.setup());
  this.drawingOrder=this.view.getDrawingOrder(this.layer.uid);this._memCache=this.view.resourceController.memoryController.getMemCache(this.layer.uid);this._controller=new aa({layerView:this});this.when(function(){a.handles.add([t.init(a,"maximumNumberOfFeatures",function(c){return a._controller.featureTarget=c}),t.whenTrue(a,"suspended",function(){return a._removeAllNodeData()})])})};b.prototype.destroy=function(){this.graphics3d&&(this.graphics3d.destroy(),this._set("graphics3d",null));this._controller&&
  (this._controller.destroy(),this._controller=null);this._memCache.destroy();this._nodesAddedToStage=this._elevationUpdateNodes=this._memCache=null};Object.defineProperty(b.prototype,"maximumNumberOfFeatures",{get:function(){var a=this.graphics3d&&this.graphics3d.graphicsCore&&this.graphics3d.graphicsCore.displayFeatureLimit;return a?a.maximumNumberOfFeatures:0},set:function(a){null!=a?(this._override("maximumNumberOfFeatures",a),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),
  this._controller.fixedFeatureTarget=!1)},enumerable:!0,configurable:!0});Object.defineProperty(b.prototype,"maximumNumberOfFeaturesExceeded",{get:function(){return this.suspended?!1:!!this._controller&&!this._controller.leafsReached},enumerable:!0,configurable:!0});b.prototype.whenGraphicAttributes=function(a,c){var b=this;return y.whenGraphicAttributes(this.layer,a,this._getObjectIdField(),c,function(a){for(var c=new Map,e=[],m=0;m<a.length;m++){var l=a[m],g=b._findGraphicNodeAndIndex(l),f=c.get(g.node);
  f||(f={node:g.node,indices:[],graphics:[]},e.push(f));f.indices.push(g.index);f.graphics.push(l)}return e},{ignoreUnavailableFields:!0,populateObjectId:!0})};b.prototype.getGraphicFromGraphicUid=function(a){if(!this.loadedGraphics)return null;var c=A.hydrateGraphic(this.loadedGraphics.find(function(c){return c.uid===a}),this.layer),b=this._getObjectIdField();if(!c||!c.attributes||!c.attributes[b])return null;c.layer=this.layer;c.sourceLayer=this.layer;return c};b.prototype.whenGraphicBounds=function(a,
  c){return this.graphics3d.graphicsCore.whenGraphicBounds(a,c)};b.prototype.canResume=function(){return this.inherited(arguments)&&(!this._controller||this._controller.rootNodeVisible)};b.prototype.isUpdating=function(){return this.overlayUpdating||this._controller&&this._controller.updating||this.graphics3d&&this.graphics3d.updating};b.prototype.getRenderingInfo=function(a,c){(a=ba.getRenderingInfo(a,{renderer:c}))&&a.color&&(c=a.color,c[0]/=255,c[1]/=255,c[2]/=255);return a};Object.defineProperty(b.prototype,
  "symbolUpdateType",{get:function(){return this.graphics3d.graphicsCore.symbolUpdateType},enumerable:!0,configurable:!0});b.prototype._findGraphicNodeAndIndex=function(a){a=a.attributes[this.layer.objectIdField];for(var c=0,b=O.keysOfMap(this._nodesAddedToStage);c<b.length;c++){var e=b[c],d=this._nodesAddedToStage.get(e),d=this._findGraphicIndex(d.bundle,a);if(0<=d)return{node:this._controller.getNode(e),index:d}}return null};b.prototype._forAllFeatures=function(a,c){this._nodesAddedToStage.forEach(function(b,
  e){b=b.bundle;for(var d=0;d<b.length;d++)for(var m=b[d].graphics,k=0;k<m.length;k++){var l=m[k],g=b[d].featureIds[k];l.visible&&a(g,d,l)}null!=c&&c({nodeId:e})})};b.prototype._getGraphicIndices=function(a,c){a=this._nodesAddedToStage.get(a);for(var b=this._getObjectIdField(),e=[],d=0;d<c.length;d++){var F=this._findGraphicIndex(a.bundle,c[d].attributes[b]);0<=F&&e.push(F)}return e};b.prototype._findGraphicIndex=function(a,c){for(var b=0;b<a.length;b++)for(var e=0,d=a[b].featureIds;e<d.length;e++)if(d[e]===
  c)return b;return-1};b.prototype._queryGraphicUIDsInExtent=function(a,c,b){if(this._controller){var e=this._controller.crsIndex;E.boundingRectToBoundingRect(a,c,v,e);var d=ma;u.fromRect(d,v);d[2]=-Infinity;d[5]=Infinity;null==this._elevationUpdateNodes&&(this._elevationUpdateNodes=new W);var m=this._elevationUpdateNodes;this._controller.updateElevationChanged(d,e,m);for(e=0;e<m.length;e++){var k=this._nodesAddedToStage.get(m.data[e].id);if(null!=k){if(!k.spatialIndex&&k.bundle.length>=na){for(var l=
  new Y.PooledRBush(9,U("csp-restrictions")?function(a){return{minX:a.extent[0],minY:a.extent[1],maxX:a.extent[2],maxY:a.extent[3]}}:[".extent[0]",".extent[1]",".extent[2]",".extent[3]"]),g=K.length=0,f=k.bundle;g<f.length;g++){for(var h=f[g],B=P.empty(),w=0,C=h.graphics;w<C.length;w++)d=C[w],A.expandAABR(d.geometry,B);h.extent=B;K.push(h)}l.load(K);k.spatialIndex=l}if(k.spatialIndex)d=v,E.boundingRectToBoundingRect(a,c,v,this.view.spatialReference),x.minX=d[0],x.minY=d[1],x.maxX=d[2],x.maxY=d[3],k.spatialIndex.search(x,
  function(a){var c=0;for(a=a.graphics;c<a.length;c++)b(a[c].uid)});else for(l=0,k=k.bundle;l<k.length;l++)for(h=k[l],g=0,h=h.graphics;g<h.length;g++)d=h[g],b(d.uid)}}}};b.prototype.highlight=function(a,c){void 0===c&&(c={});return this.graphics3d.highlight(a,c,this.layer.objectIdField)};b.prototype.addNodeData=function(a,c){if(this._nodesAddedToStage.has(a.id))G.error("I3S node "+a.id+" already added");else{var b=c.allGeometryData,e=c.attributeDataInfo,d=this._controller.crsIndex;c=this.view.spatialReference;
  var f=[0,0,0],k=this._getObjectIdField(),l=[],g;if(g=this.layer.fullExtent)g=this.layer.fullExtent.clone(),g.xmin-=.5,g.ymin-=.5,g.xmax+=.5,g.ymax+=.5,g.hasZ&&(g.zmin-=.5,g.zmax+=.5),g.hasM&&(g.mmin-=.5,g.mmax+=.5);var h=g;g=[];for(var r=[],B=0;B<b.length;B++){var w=b[B],C=w.featureDataPosition,n=C.length,u=w.geometries||[oa[n]],x=w.featureIds;h&&!Z.extentContainsCoords3D(h,C)&&(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&G.error("Service Error: Coordinates outside of layer extent"),
  this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&G.error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++);for(var q=0;q<u.length;q++){var z=u[q];if("points"===z.params.type){var t=[],D=x[q<x.length?q:0],y={};null!=D&&(y[k]=D);var D=null==D?T.generateUID():D,v=void 0;"Embedded"===z.type&&(v=z.params.vertexAttributes.position);for(z=0;z<v.length;z+=n){for(var p=0;p<n;p++)f[p]=C[p]+v[z+p];E.bufferToBuffer(f,d,0,
  I,c,0,1);p=A.makeDehydratedPoint(I[0],I[1],I[2],c);3>n&&(p.z=void 0);t.push({uid:D,geometry:p,attributes:y,visible:!0});a.obb||r.push(p.x,p.y,p.z?p.z:0)}g.push.apply(g,t);l.push({featureIds:w.featureIds,graphics:t})}}}a.numFeatures=g.length;this._updateNodeMemory(a);b={bundle:l,attributeInfo:e};R(b.bundle,b.attributeInfo);0<r.length&&(e=this.view.renderSpatialReference,d=this._controller.crsVertex,E.bufferToBuffer(r,c,0,r,e,0,r.length/3),a.obb=ka.compute({data:r,size:3,offsetIdx:0,strideIdx:3}),E.vectorToVector(a.obb.center,
  e,a.obb.center,d),this._controller.updateVisibility(a.id));if(!this._controller.isGeometryVisible(a))return this._cacheNodeData(a.id,b),H.resolve();this._verticalScale&&this._verticalScale.adjust(g);this._nodesAddedToStage.set(a.id,b);this.loadedGraphics.addMany(g);this._filterNode(b);return H.resolve()}};b.prototype.isNodeLoaded=function(a){return this._nodesAddedToStage.has(a.id)};b.prototype._updateNodeMemory=function(a){a.memory=4096+a.numFeatures*this.graphics3d.graphicsCore.usedMemoryPerGraphic};
  b.prototype._cacheNodeData=function(a,b){var c=b.bundle.reduce(function(a,b){return b.graphics.reduce(function(a,b){return A.estimateSize(b)+a},512+8*b.featureIds.length+a)},1024);this._memCache.put(a,b,c)};b.prototype._removeAllNodeData=function(){var a=this;this._nodesAddedToStage.forEach(function(b,m){if(b){var c=a._controller.getNode(m);a._updateNodeMemory(c);a._cacheNodeData(m,b)}});this._nodesAddedToStage.clear();this.loadedGraphics.clear()};b.prototype.removeNodeData=function(a,b){for(;0<a.length&&
  !b.done;){var c=a.pop(),e=this._removeNodeStageData(c);e&&(this._updateNodeMemory(c),this._cacheNodeData(c.id,e));b.madeProgress()}};b.prototype._removeNodeStageData=function(a){var b=this._nodesAddedToStage.get(a.id);if(!b)return null;for(var m=0,e=b.bundle;m<e.length;m++)this.loadedGraphics.removeMany(e[m].graphics);this._nodesAddedToStage.delete(a.id);return b};b.prototype.loadCachedNodeData=function(a,b){return H.resolve(this._memCache.pop(a.id))};b.prototype.addCachedNodeData=function(a,b,m){if(this._nodesAddedToStage.has(a.id))G.error("I3S node "+
  a.id+" already added");else{for(var c=0,d=b.bundle;c<d.length;c++)this.loadedGraphics.addMany(d[c].graphics);this._nodesAddedToStage.set(a.id,b);this._updateNodeMemory(a);this.setAttributeData(a,m);this._filterNode(b);return H.resolve()}};b.prototype.getLoadedNodeIDs=function(){return O.keysOfMap(this._nodesAddedToStage)};b.prototype.getLoadedAttributes=function(a){if(a=this._nodesAddedToStage.get(a.id))return a.attributeInfo.loadedAttributes};b.prototype.getAttributeData=function(a){if(a=this._nodesAddedToStage.get(a.id))return a.attributeInfo.attributeData};
  b.prototype.setAttributeData=function(a,b){if(a=this._nodesAddedToStage.get(a.id))a.attributeInfo=b,R(a.bundle,b),this._filterNode(a),this.graphics3d.graphicsCore.labelsEnabled&&(b=a.bundle.map(function(a){return a.graphics.length&&a.graphics[0].uid}),this.graphics3d.graphicsCore.updateLabelingInfo(b))};b.prototype._updateClippingExtent=function(a){this._controller&&this._controller.updateClippingArea(a);return!1};b.prototype._getObjectIdField=function(){return this.layer.objectIdField||"OBJECTID"};
  b.prototype._rendererChange=function(a,b){return M(this,void 0,void 0,function(){var c,e,d,f;return L(this,function(k){switch(k.label){case 0:return c=this.layer.fields,e=new N.default,a?[4,a.collectRequiredFields(e,c)]:[3,2];case 1:return k.sent(),d=J.from(e).sort(),[3,3];case 2:d=[],k.label=3;case 3:return e.clear(),b?[4,b.collectRequiredFields(e,c)]:[3,5];case 4:return k.sent(),f=J.from(e).sort(),[3,6];case 5:f=[],k.label=6;case 6:if(d.length===f.length&&d.every(function(a,b){return d[b]===f[b]}))return[2];
  this._reloadAllNodes();return[2]}})})};b.prototype._rangeInfosChanged=function(a){null!=a&&0<a.length&&G.warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")};b.prototype._filterChange=function(){var a=this;this._nodesAddedToStage.forEach(function(b){return a._filterNode(b)})};b.prototype._reloadAllNodes=function(){this._removeAllNodeData();this._controller&&this._controller.restartNodeLoading()};b.prototype._filterNode=function(a){var b=
  this._getObjectIdField(),f=null;if(this.layer.objectIdFilter)var e=this.layer.objectIdFilter.ids,d="include"===this.layer.objectIdFilter.method,f=function(a){return 0<=e.indexOf(a)===d};var h=this.parsedDefinitionExpression,k=0;for(a=a.bundle;k<a.length;k++)for(var l=0,g=a[k].graphics;l<g.length;l++){var n=g[l],r=n.visible;f&&!f(n.attributes[b])?n.visible=!1:n.visible=h?this._evaluateClause(h,n):!0;r!==n.visible&&(q.graphic=n,q.property="visible",q.oldValue=r,q.newValue=n.visible,this.graphics3d.graphicsCore.graphicUpdateHandler(q))}};
  b.prototype._updateRequiredFields=function(){return M(this,void 0,void 0,function(){var a,b,f,e,d,h,k,l;return L(this,function(c){switch(c.label){case 0:return a=this,f=b=a.layer,e=f.fields,d=f.renderer,h=f.labelsVisible,k=a.definitionExpressionFields,l=new N.default,d?[4,d.collectRequiredFields(l,e)]:[3,2];case 1:c.sent(),c.label=2;case 2:return h?[4,Q.collectLabelingFields(l,b)]:[3,4];case 3:c.sent(),c.label=4;case 4:return Q.collectFields(l,e,k),this._set("requiredFields",J.from(l).sort()),[2]}})})};
  b.prototype.queryExtent=function(a){return this._ensureQueryEngine().queryExtent(a)};b.prototype.queryFeatureCount=function(a){return this._ensureQueryEngine().queryFeatureCount(a)};b.prototype.queryFeatures=function(a){return this._ensureQueryEngine().queryFeatures(a)};b.prototype.queryObjectIds=function(a){return this._ensureQueryEngine().queryObjectIds(a)};b.prototype._ensureQueryEngine=function(){this._queryEngine||(this._queryEngine=this._createQueryEngine());return this._queryEngine};b.prototype._createQueryEngine=
  function(){var a=this,b={id:0,index:0,graphic:null},f=this;return new fa(this.layer,{forAll:function(c,d){a._forAllFeatures(function(a,d,e){b.id=a;b.index=d;b.graphic=e;c(b)},d)},createGraphic:function(a){return A.hydrateGraphic(a.graphic,f.layer)},requestFields:function(b,c,f){return y.whenGraphicAttributes(a.layer,c,a._getObjectIdField(),f,function(c){var d=a._getGraphicIndices(b.nodeId,c);return[{node:a._controller.getNode(b.nodeId),indices:d,graphics:c}]},{ignoreUnavailableFields:!1})},createExtentBuilder:function(){var b=
  u.empty(),c=a.layer.spatialReference;return{add:function(a){return A.expandAABB(a.graphic.geometry,b)},getExtent:function(){return u.toExtent(b,c)}}}},{enableObjectId:!0,enableOutFields:!!this.layer.objectIdField})};b.prototype.getUsedMemory=function(){var a=this.graphics3d&&this.graphics3d.graphicsCore;return a?a.usedMemory:0};b.prototype.getUnloadedMemory=function(){var a=this.graphics3d&&this.graphics3d.graphicsCore;return.8*((this._controller?this._controller.unloadedMemoryEstimate:0)+(a?a.unprocessedMemoryEstimate:
  0))};b.prototype.ignoresMemoryFactor=function(){return this._controller&&this._controller.fixedFeatureTarget};b.prototype.getNumberOfNodes=function(){return this._nodesAddedToStage.size};b.prototype.getNumberOfFeatures=function(){return this.loadedGraphics.length};b.prototype.getStats=function(){var a=this.graphics3d.graphicsCore.getStats();a.nodes=this.getNumberOfNodes();a.features=this.loadedGraphics.length;this._controller&&this._controller.updateStats(a);return a};h([f.property()],b.prototype,
  "graphics3d",void 0);h([f.property()],b.prototype,"drawingOrder",void 0);h([f.property({aliasOf:"graphics3d.graphicsCore.hasDraped"})],b.prototype,"hasDraped",void 0);h([f.property({type:Boolean})],b.prototype,"overlayUpdating",void 0);h([f.property({type:Boolean})],b.prototype,"supportsDraping",void 0);h([f.property({type:la})],b.prototype,"filter",void 0);h([f.property()],b.prototype,"loadedGraphics",void 0);h([f.property()],b.prototype,"layer",void 0);h([f.property()],b.prototype,"_controller",
  void 0);h([f.property({dependsOn:["_controller.updating","graphics3d.updating","overlayUpdating"]})],b.prototype,"updating",void 0);h([f.property({dependsOn:["_controller.rootNodeVisible"]})],b.prototype,"suspended",void 0);h([f.property(ha.updatingPercentage)],b.prototype,"updatingPercentage",void 0);h([f.property({aliasOf:"_controller.updatingPercentage"})],b.prototype,"updatingPercentageValue",void 0);h([f.property({readOnly:!0})],b.prototype,"requiredFields",void 0);h([f.property({type:Number,
  dependsOn:["graphics3d.graphicsCore.displayFeatureLimit"]})],b.prototype,"maximumNumberOfFeatures",null);h([f.property({readOnly:!0,dependsOn:["suspended","_controller.leafsReached"]})],b.prototype,"maximumNumberOfFeaturesExceeded",null);h([f.property({readOnly:!0,aliasOf:"view.qualitySettings.sceneService.point.lodFactor"})],b.prototype,"lodFactor",void 0);return b=h([f.subclass("esri.views.3d.layers.SceneLayerGraphicsView3D")],b)}(f.declared(ca,ia.PopupSceneLayerView,ga.DefinitionExpressionSceneLayerView));
  var oa={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},na=100,v=P.create(),ma=u.create(u.POSITIVE_INFINITY),x={minX:0,minY:0,maxX:0,maxY:0},I=X.vec3f64.create(),K=[],q={graphic:null,property:null,oldValue:null,newValue:null};return n});