/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import r from"../../../PopupTemplate.js";import i from"../../../core/Collection.js";import{watch as s,initial as t}from"../../../core/reactiveUtils.js";import{isScreenRect as o}from"../../../core/screenUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators.js";import p from"../../../graphic/GeoRSSGraphicOrigin.js";import l from"../../../renderers/SimpleRenderer.js";import{fromJSON as n}from"../../../renderers/support/jsonUtils.js";import h from"../../../rest/support/FeatureSet.js";import{LayerView2D as c}from"./LayerView2D.js";import m from"./graphics/GraphicContainer.js";import y from"./graphics/GraphicsView2D.js";import g from"../../layers/GeoRSSLayerView.js";let f=class extends(c(g)){constructor(){super(...arguments),this._graphicsViewMap={},this.graphicsViews=[]}async hitTest(e,r){if(!this.graphicsViews.length)return null;const i=this.layer;return this.graphicsViews.reverse().flatMap(e=>e.hitTest(this.view,r)).map(s=>({type:"graphic",graphic:s,layer:i,mapPoint:o(r)?null:e}))}update(e){if(this.graphicsViews)for(const r of this.graphicsViews)r.processUpdate(e)}attach(){this.addAttachHandles([s(()=>this.layer?.featureCollections,e=>{this._clear();const{layer:s}=this,t=new p(this.layer);for(const{popupInfo:o,featureSet:a,layerDefinition:p}of e){const e=h.fromJSON(a),l=new i(e.features),c=o?r.fromJSON(o):null;l.forEach(e=>{e.layer=s,e.sourceLayer=s,e.popupTemplate=c,e.origin=t});const g=p.drawingInfo,f=n(g.renderer),w=new y({requestUpdateCallback:()=>this.requestUpdate(),view:this.view,graphics:l,renderer:f,container:new m(this.view.featuresTilingScheme)});this._graphicsViewMap[e.geometryType]=w,"polygon"!==e.geometryType||this.layer.polygonSymbol?"polyline"!==e.geometryType||this.layer.lineSymbol?"point"!==e.geometryType||this.layer.pointSymbol||(this.layer.pointSymbol=f.symbol):this.layer.lineSymbol=f.symbol:this.layer.polygonSymbol=f.symbol,this.graphicsViews.push(w),this.container.addChild(w.container)}},t),s(()=>this.layer?.polygonSymbol,e=>{this._graphicsViewMap.polygon.renderer=new l({symbol:e})},t),s(()=>this.layer?.lineSymbol,e=>{this._graphicsViewMap.polyline.renderer=new l({symbol:e})},t),s(()=>this.layer?.pointSymbol,e=>{this._graphicsViewMap.point.renderer=new l({symbol:e})},t)])}detach(){this._clear()}moveEnd(){}viewChange(){for(const e of this.graphicsViews)e.viewChange()}_clear(){this.container.removeAllChildren();for(const e of this.graphicsViews)e.destroy();this._graphicsViewMap={},this.graphicsViews.length=0}};f=e([a("esri.views.2d.layers.GeoRSSLayerView2D")],f);const w=f;export{w as default};
