/*
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/Logger","../../../core/promiseUtils","../../../core/reactiveUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../../geometry/Extent","../engine/BitmapContainer","./LayerView2D","./support/ExportStrategy","../../layers/LayerView","../../layers/RefreshableLayerView","../../layers/WMSLayerView"],(function(e,t,r,i,a,n,o,s,c,u,p,h,d,l,y,g,m){"use strict";const f=r.getLogger("esri.views.2d.layers.WMSLayerView2D");let x=function(t){function r(){var e;return(e=t.apply(this,arguments)||this).container=new h.BitmapContainer,e}e._inheritsLoose(r,t);var n=r.prototype;return n.supportsSpatialReference=function(e){return this.layer.serviceSupportsSpatialReference(e)},n.update=function(e){this.strategy.update(e).catch((e=>{i.isAbortError(e)||f.error(e)}))},n.attach=function(){const{layer:e,container:t}=this,{imageMaxHeight:r,imageMaxWidth:i}=e;this.strategy=new l({container:t,fetchSource:this.fetchImage.bind(this),requestUpdate:this.requestUpdate.bind(this),imageMaxHeight:r,imageMaxWidth:i,imageRotationSupported:!1,imageNormalizationSupported:!1,hidpi:!1}),this.handles.add(a.watch((()=>this.exportImageVersion),(()=>this.requestUpdate())),"exportImageVersion")},n.detach=function(){this.handles.remove("exportImageVersion"),this.strategy.destroy(),this.strategy=null,this.container.removeAllChildren()},n.moveStart=function(){},n.viewChange=function(){},n.moveEnd=function(){this.requestUpdate()},n.createFetchPopupFeaturesQuery=function(e){const{view:t,container:r}=this,{x:i,y:a}=e,{spatialReference:n}=t;let o=null,s=0,c=0;if(r.children.some((e=>{const{width:t,height:r,resolution:u,x:h,y:d}=e,l=h+u*t,y=d-u*r;return i>=h&&i<=l&&a<=d&&a>=y&&(o=new p({xmin:h,ymin:y,xmax:l,ymax:d,spatialReference:n}),s=t,c=r,!0)})),!o)return null;const u=o.width/s,h=Math.round((i-o.xmin)/u),d=Math.round((o.ymax-a)/u);return{extent:o,width:s,height:c,x:h,y:d}},n.doRefresh=function(){var t=e._asyncToGenerator((function*(){this.requestUpdate()}));function r(){return t.apply(this,arguments)}return r}(),n.isUpdating=function(){return this.strategy.updating||this.updateRequested},n.fetchImage=function(e,t,r,i){return this.layer.fetchImage(e,t,r,{timeExtent:this.timeExtent,...i})},r}(m(g(d.LayerView2DMixin(y))));t.__decorate([n.property()],x.prototype,"strategy",void 0),t.__decorate([n.property()],x.prototype,"updating",void 0),x=t.__decorate([u.subclass("esri.views.2d.layers.WMSLayerView2D")],x);return x}));
