/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{TypedShaderProgram as t}from"./typed/TypedShaderProgram.js";class e{constructor(){this.computeAttributes={}}get locationsMap(){const t=new Map;for(const e in this.locations)t.set(e,this.locations[e].index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set(Object.keys(this.options));this._optionPropertyKeys=t}return this._optionPropertyKeys}get _transformFeedbackBindings(){return[]}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map(([t,e])=>`${t}.${e}`).join(".");this._locationInfo={stringHash:e,locations:t,computeAttributeMap:this.computeAttributes}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const[e,n]of this.locationsMap.entries())t.set("a_"+e,n);return t}getShaderKey(t,e,n,o,r){return`${Object.keys(t).map(e=>`${e}.${t[e]}`).join(".")}.${Object.keys(o).filter(t=>o[t]).map(t=>`${t}_${o[t].toString()}`).join(".")}.${Object.keys(e).filter(t=>this.optionPropertyKeys.has(t)).join(".")}.${Object.keys(n).filter(t=>n[t]).join(".")}`}getProgram(e,n,o,r){let i="",s="";for(const t in o)if(o[t]){const e="boolean"==typeof o[t]?`#define ${t}\n`:`#define ${t} ${o[t]}\n`;i+=e,s+=e}return i+=this.vertexShader,s+=this.fragmentShader,new t("glslShaderModule",i,s,this.renamedLocationsMap,this._getUniformBindings(n),this._getTextureBindings(),this._transformFeedbackBindings)}_getUniformBindings(t){const e=[];for(const r in this.required){const t=this.required[r];e.push({uniformHydrated:null,shaderModulePath:r,uniformName:r,uniformType:t.type,uniformArrayElementType:n(t),uniformArrayLength:o(t)})}for(const r in t){const i=this.options[r];if(t[r])for(const t in i){const s=i[t];e.push({uniformHydrated:null,shaderModulePath:`${r}.${t}`,uniformName:t,uniformType:s.type,uniformArrayElementType:n(s),uniformArrayLength:o(s)})}}return e}_getTextureBindings(){const t=[];for(const e in this.textures)t.push({textureHydrated:null,shaderModulePath:e,textureName:e});return t}}const n=t=>"array"===t.type?t.elementType?.type:void 0,o=t=>"array"===t.type?t.size:void 0;export{e as GLSLShaderModule};
