/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/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 r(e){const t=new Blob([e]),r=await t.text();return JSON.parse(r)}async function n(t,r){if("image/ktx2"===r)return new e(t);const n=new Blob([t],{type:r});let o=URL.createObjectURL(n);switch(r){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 r=()=>{s(),e(c)},n=e=>{s(),t(e)},s=()=>{URL.revokeObjectURL(o),c.removeEventListener("load",r),c.removeEventListener("error",n)};c.addEventListener("load",r),c.addEventListener("error",n),c.src=o});try{c.src=o,await c.decode()}catch{}return URL.revokeObjectURL(o),c}export{e as EncodedMeshTexture,n as imageFromBinaryData,t as isEncodedMeshTexture,r as jsonFromBinaryData};
