/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../../chunks/_rollupPluginBabelHelpers","../../../../chunks/tslib.es6","../../../../core/Accessor","../../../../core/Logger","../../../../core/maybe","../../../../core/promiseUtils","../../../../core/accessorSupport/decorators/property","../../../../core/arrayUtils","../../../../core/has","../../../../core/accessorSupport/ensureType","../../../../core/accessorSupport/decorators/subclass","../../../../geometry/Extent","../../engine/imagery/RasterVFDisplayObject"],(function(e,t,r,i,o,a,s,n,l,c,p,d,y){"use strict";const h=i.getLogger("esri.views.2d.layers.imagery.VectorFieldView2D");let u=function(t){function r(e){var r;return(r=t.call(this,e)||this).update=a.debounce(((e,t)=>r._update(e,t).catch((e=>{a.isAbortError(e)||h.error(e)})))),r}e._inheritsLoose(r,t);var i=r.prototype;return i.redraw=function(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()},i._update=function(){var t=e._asyncToGenerator((function*(e,t,r){if(!e.stationary)return;const{extent:i,spatialReference:o}=e.state,a=new d({xmin:i.xmin,ymin:i.ymin,xmax:i.xmax,ymax:i.ymax,spatialReference:o}),[s,n]=e.state.size;this._loading=this.fetchPixels(a,s,n,r);const l=yield this._loading;this._addToDisplay(l,t,e.state),this._loading=null}));function r(e,r,i){return t.apply(this,arguments)}return r}(),i._addToDisplay=function(e,t,r){if(o.isNone(e.pixelBlock))return this.container.children.forEach((e=>e.destroy())),void this.container.removeAllChildren();const{extent:i,pixelBlock:a}=e,s=new y.RasterVFDisplayObject(a);s.offset=[0,0],s.symbolizerParameters=t,s.rawPixelData=e,s.invalidateVAO(),s.x=i.xmin,s.y=i.ymax,s.pixelRatio=r.pixelRatio,s.rotation=r.rotation,s.resolution=r.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._createClass(r,[{key:"updating",get:function(){return!!this._loading}}]),r}(r);t.__decorate([s.property()],u.prototype,"fetchPixels",void 0),t.__decorate([s.property()],u.prototype,"container",void 0),t.__decorate([s.property()],u.prototype,"_loading",void 0),t.__decorate([s.property()],u.prototype,"updating",null),u=t.__decorate([p.subclass("esri.views.2d.layers.imagery.ImageryVFStrategy")],u);return u}));
