/*
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","../../../Graphic","../../../core/Collection","../../../core/reactiveUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../../support/GraphicsCollection","../engine/flow/FlowView2D","./LayerView2D","./graphics/GraphicsView2D","./graphics/HighlightGraphicContainer","./imagery/ImageryView2D","./imagery/VectorFieldView2D","../../layers/ImageryLayerView","../../layers/LayerView","../../layers/RefreshableLayerView"],(function(e,t,i,r,s,a,n,h,o,l,u,c,w,d,p,y,v,g,b,f){"use strict";let m=function(t){function a(){var e;return(e=t.apply(this,arguments)||this)._exportImageVersion=-1,e._highlightGraphics=new u.GraphicsCollection,e.subview=null,e}e._inheritsLoose(a,t);var n=a.prototype;return n.hitTest=function(){var t=e._asyncToGenerator((function*(e,t){return this.subview?[{type:"graphic",graphic:this.subview.hitTest(e),layer:this.layer,mapPoint:e}]:null}));function i(e,i){return t.apply(this,arguments)}return i}(),n.update=function(e){var t;null==(t=this.subview)||t.update(e)},n.attach=function(){this.layer.increaseRasterJobHandlerUsage(),this._setSubView(),this.view&&(this._highlightView=new d({view:this.view,graphics:this._highlightGraphics,requestUpdateCallback:()=>this.requestUpdate(),container:new p(this.view.featuresTilingScheme)}),this.container.addChild(this._highlightView.container)),this.handles.add([s.watch((()=>{var e;return null!=(e=this.layer.blendMode)?e:"normal"}),(e=>this.subview.container.blendMode=e),s.syncAndInitial),s.watch((()=>{var e;return null!=(e=this.layer.effect)?e:null}),(e=>this.subview.container.effect=e),s.syncAndInitial),s.watch((()=>this.layer.exportImageServiceParameters.version),(e=>{e&&this._exportImageVersion!==e&&(this._exportImageVersion=e,this.requestUpdate())}),s.sync),s.watch((()=>this.timeExtent),(e=>{this.subview.timeExtent=e,"redraw"in this.subview?this.requestUpdate():this.subview.redrawOrRefetch()}),s.sync),this.layer.on("redraw",(()=>{"redraw"in this.subview?this.subview.redraw():this.subview.redrawOrRefetch()})),s.watch((()=>this.layer.renderer),(()=>this._setSubView()))],"imagerylayerview-update")},n.detach=function(){var e,t;this.layer.decreaseRasterJobHandlerUsage(),this.container.removeAllChildren(),this._detachSubview(this.subview),null==(e=this.subview)||e.destroy(),this.handles.remove("imagerylayerview-update"),this.subview=null,null==(t=this._highlightView)||t.destroy(),this._exportImageVersion=-1},n.moveStart=function(){},n.viewChange=function(){},n.moveEnd=function(){this.requestUpdate()},n.highlight=function(e,t){if(!((Array.isArray(e)?e[0]:r.isCollection(e)?e.getItemAt(0):e)instanceof i))return{remove:()=>{}};let s=[];return Array.isArray(e)||r.isCollection(e)?s=e.map((e=>e.clone())):e instanceof i&&(s=[e.clone()]),this._highlightGraphics.addMany(s),{remove:()=>{this._highlightGraphics.removeMany(s)}}},n.doRefresh=function(){var t=e._asyncToGenerator((function*(){this.requestUpdate()}));function i(){return t.apply(this,arguments)}return i}(),n.isUpdating=function(){return!this.subview||this.subview.updating},n._setSubView=function(){var e;if(!this.view)return;const t=null==(e=this.layer.renderer)?void 0:e.type;let i="imagery";if("vector-field"===t?i="imageryVF":"flow"===t&&(i="flow"),this.subview){var r;if(this.subview.type===i)return this._attachSubview(this.subview),void("flow"===this.subview.type&&this.subview.redrawOrRefetch());this._detachSubview(this.subview),null==(r=this.subview)||r.destroy()}this.subview="imagery"===i?new y({layer:this.layer,view:this.view,timeExtent:this.timeExtent}):"imageryVF"===i?new v({layer:this.layer,view:this.view,timeExtent:this.timeExtent}):new c({layer:this.layer,layerView:this}),this._attachSubview(this.subview),this.requestUpdate()},n._attachSubview=function(e){e&&!e.attached&&(e.attach(),e.attached=!0,this.container.addChildAt(e.container,0),e.container.blendMode=this.layer.blendMode,e.container.effect=this.layer.effect)},n._detachSubview=function(e){null!=e&&e.attached&&(this.container.removeChild(e.container),e.detach(),e.attached=!1)},e._createClass(a,[{key:"pixelData",get:function(){return this.updating?null:"getPixelData"in this.subview?this.subview.getPixelData():null}},{key:"updating",get:function(){return!!(!this.subview||"updating"in this.subview&&this.subview.updating)}}]),a}(g(f(w.LayerView2DMixin(b))));t.__decorate([a.property()],m.prototype,"pixelData",null),t.__decorate([a.property({readOnly:!0})],m.prototype,"updating",null),t.__decorate([a.property()],m.prototype,"subview",void 0),m=t.__decorate([l.subclass("esri.views.2d.layers.ImageryLayerView2D")],m);return m}));
