/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import has from"../../../../core/has.js";class e{constructor(e){this.data=e,this.type="encoded-mesh-texture",this.encoding="image/ktx2"}}function t(e){return"encoded-mesh-texture"===e?.type}async function n(e){const t=new Blob([e]),n=await t.text();return JSON.parse(n)}async function r(t,n){if("image/ktx2"===n)return new e(t);const r=new Blob([t],{type:n});let o=URL.createObjectURL(r);switch(n){case"image/jpeg":o+="#.jpg";break;case"image/png":o+="#.png"}const c=new Image;if(has("esri-iPhone"))return new Promise((e,t)=>{const n=()=>{s(),e(c)},r=e=>{s(),t(e)},s=()=>{URL.revokeObjectURL(o),c.removeEventListener("load",n),c.removeEventListener("error",r)};c.addEventListener("load",n),c.addEventListener("error",r),c.src=o});try{c.src=o,await c.decode()}catch(s){console.warn("Failed decoding HTMLImageElement")}return URL.revokeObjectURL(o),c}export{e as EncodedMeshTexture,r as imageFromBinaryData,t as isEncodedMeshTexture,n as jsonFromBinaryData};
