/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{createProgramTemplate as r}from"./shaders/MaterialPrograms.js";class e{constructor(r){this._rctx=r,this._programByKey=new Map}dispose(){this._programByKey.forEach(r=>r.dispose()),this._programByKey.clear()}getProgram(e,a=[]){const t=e.vsPath+"."+e.fsPath+JSON.stringify(a);if(this._programByKey.has(t))return this._programByKey.get(t);const s={...a.map(r=>"string"==typeof r?{name:r,value:!0}:r).reduce((r,e)=>({...r,[e.name]:e.value}),{})},{vsPath:o,fsPath:h,locations:i}=e,g=r(o,h,s),m=this._rctx.programCache.acquire(g.vertexShader,g.fragmentShader,i);if(!m)throw new Error("Unable to get program for key: ${key}");return this._programByKey.set(t,m),m}}export{e as default};
