/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../chunks/_rollupPluginBabelHelpers","../../../../../chunks/tslib.es6","../../../../../assets","../../../../../core/Accessor","../../../../../core/Logger","../../../../../core/accessorSupport/decorators/property","../../../../../core/arrayUtils","../../../../../core/has","../../../../../core/accessorSupport/ensureType","../../../../../core/accessorSupport/decorators/subclass","../../../../../support/requestImageUtils","../../lib/basicInterfaces","../../../../webgl/enums","../../../../webgl/Texture"],(function(e,t,r,a,s,o,i,u,n,p,c,l,d,_,g){"use strict";const h=o.getLogger("esri.views.3d.webgl-engine.materials.internal.waterMaterialUtils");e.WaterTextureRepository=function(e){function r(){var t;return(t=e.apply(this,arguments)||this)._data=new Array,t._state=d.ResourceState.NOT_LOADED,t}t._inheritsLoose(r,e);var s=r.prototype;return s.dispose=function(){this._state=d.ResourceState.NOT_LOADED,this._data.forEach((e=>e.dispose())),this._data.length=0},s.loadTextures=function(e){const t=[a.getAssetUrl("esri/images/materials/water/normals.jpg"),a.getAssetUrl("esri/images/materials/water/perturbation.jpg")];this._state=d.ResourceState.LOADING,Promise.all(t.map((e=>l.requestImage(e)))).then((t=>{t.forEach((t=>this._data.push(new g.Texture(e,{target:_.TextureType.TEXTURE_2D,pixelFormat:_.PixelFormat.RGBA,dataType:_.PixelType.UNSIGNED_BYTE,wrapMode:_.TextureWrapMode.REPEAT,samplingMode:_.TextureSamplingMode.LINEAR_MIPMAP_LINEAR,hasMipmap:!0,maxAnisotropy:8,width:t.width,height:t.height},t)))),this._state=d.ResourceState.LOADED})).catch((e=>{h.error("Failed to load textures for water material.",e),this._state=d.ResourceState.NOT_LOADED}))},s.bind=function(e){this._state===d.ResourceState.LOADED&&(e.bindTexture("texWaveNormal",this._data[0]),e.bindTexture("texWavePerturbation",this._data[1]))},t._createClass(r,[{key:"updating",get:function(){return this._state===d.ResourceState.LOADING}},{key:"resourceState",get:function(){return this._state}}]),r}(s),r.__decorate([i.property()],e.WaterTextureRepository.prototype,"_state",void 0),r.__decorate([i.property({type:Boolean,readOnly:!0})],e.WaterTextureRepository.prototype,"updating",null),e.WaterTextureRepository=r.__decorate([c.subclass("esri.views.3d.webgl-engine.materials.internal.WaterTextureRepository")],e.WaterTextureRepository),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
