/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{debounce as r,isAbortError as a}from"../../../../core/promiseUtils.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import n from"../../../../geometry/Extent.js";import{RasterVFDisplayObject as l}from"../../engine/imagery/RasterVFDisplayObject.js";let c=class extends t{constructor(e){super(e),this._loading=null,this.update=r((e,t)=>this._update(e,t).catch(e=>{a(e)||i.getLogger(this).error(e)}))}get updating(){return!!this._loading}redraw(e){if(!this.container.children.length)return;const t=this.container.children[0];t.symbolizerParameters=e,t.invalidateMeshes(),this.container.symbolTypes="wind_speed"===e.style?["scalar","triangle"]:"simple_scalar"===e.style?["scalar"]:["triangle"],this.container.requestRender()}async _update(e,t,i){if(!e.stationary)return;const{extent:r,spatialReference:a}=e.state,s=new n({xmin:r.xmin,ymin:r.ymin,xmax:r.xmax,ymax:r.ymax,spatialReference:a}),[o,l]=e.state.size;this._loading=this.fetchPixels(s,o,l,i);const c=await this._loading;this._addToDisplay(c,t,e.state),this._loading=null}_addToDisplay(e,t,i){if(null==e.pixelBlock||null==e.magdirData)return this.container.children.forEach(e=>e.destroy()),void this.container.removeAllChildren();const{extent:r,magdirData:a}=e,s=new l(a);s.offset=[0,0],s.symbolizerParameters=t,s.rawPixelData=e,s.invalidateMeshes(),s.x=r.xmin,s.y=r.ymax,s.pixelRatio=i.pixelRatio,s.rotation=i.rotation,s.resolution=i.resolution,s.width=a.width*t.symbolTileSize,s.height=a.height*t.symbolTileSize,this.container.children.forEach(e=>e.destroy()),this.container.removeAllChildren(),this.container.symbolTypes="wind_speed"===t.style?["scalar","triangle"]:"simple_scalar"===t.style?["scalar"]:["triangle"],this.container.addChild(s)}};e([s()],c.prototype,"fetchPixels",void 0),e([s()],c.prototype,"container",void 0),e([s()],c.prototype,"_loading",void 0),e([s()],c.prototype,"updating",null),c=e([o("esri.views.2d.layers.imagery.ImageryVFStrategy")],c);export{c as default};
