/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{debounce as r,isAbortError as o}from"../../../../core/promiseUtils.js";import{property as a,subclass as s}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=>{o(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.invalidateVAO(),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:o}=e.state,a=new n({xmin:r.xmin,ymin:r.ymin,xmax:r.xmax,ymax:r.ymax,spatialReference:o}),[s,l]=e.state.size;this._loading=this.fetchPixels(a,s,l,i);const c=await this._loading;this._addToDisplay(c,t,e.state),this._loading=null}_addToDisplay(e,t,i){if(null==e.pixelBlock)return this.container.children.forEach(e=>e.destroy()),void this.container.removeAllChildren();const{extent:r,pixelBlock:o}=e,a=new l(o);a.offset=[0,0],a.symbolizerParameters=t,a.rawPixelData=e,a.invalidateVAO(),a.x=r.xmin,a.y=r.ymax,a.pixelRatio=i.pixelRatio,a.rotation=i.rotation,a.resolution=i.resolution,a.width=o.width*t.symbolTileSize,a.height=o.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(a)}};e([a()],c.prototype,"fetchPixels",void 0),e([a()],c.prototype,"container",void 0),e([a()],c.prototype,"_loading",void 0),e([a()],c.prototype,"updating",null),c=e([s("esri.views.2d.layers.imagery.ImageryVFStrategy")],c);export{c as default};
