define(["./when-4bbc8319","./RuntimeError-346a3079","./WebGLConstants-1c8239cc","./createTaskProcessorWorker"],(function(_,R,A,t){"use strict";var e={UNSIGNED_BYTE:A.WebGLConstants.UNSIGNED_BYTE,UNSIGNED_SHORT:A.WebGLConstants.UNSIGNED_SHORT,UNSIGNED_INT:A.WebGLConstants.UNSIGNED_INT,FLOAT:A.WebGLConstants.FLOAT,HALF_FLOAT:A.WebGLConstants.HALF_FLOAT_OES,UNSIGNED_INT_24_8:A.WebGLConstants.UNSIGNED_INT_24_8,UNSIGNED_SHORT_4_4_4_4:A.WebGLConstants.UNSIGNED_SHORT_4_4_4_4,UNSIGNED_SHORT_5_5_5_1:A.WebGLConstants.UNSIGNED_SHORT_5_5_5_1,UNSIGNED_SHORT_5_6_5:A.WebGLConstants.UNSIGNED_SHORT_5_6_5,toWebGLConstant:function(_,R){switch(_){case e.UNSIGNED_BYTE:return A.WebGLConstants.UNSIGNED_BYTE;case e.UNSIGNED_SHORT:return A.WebGLConstants.UNSIGNED_SHORT;case e.UNSIGNED_INT:return A.WebGLConstants.UNSIGNED_INT;case e.FLOAT:return A.WebGLConstants.FLOAT;case e.HALF_FLOAT:return R.webgl2?A.WebGLConstants.HALF_FLOAT:A.WebGLConstants.HALF_FLOAT_OES;case e.UNSIGNED_INT_24_8:return A.WebGLConstants.UNSIGNED_INT_24_8;case e.UNSIGNED_SHORT_4_4_4_4:return A.WebGLConstants.UNSIGNED_SHORT_4_4_4_4;case e.UNSIGNED_SHORT_5_5_5_1:return A.WebGLConstants.UNSIGNED_SHORT_5_5_5_1;case e.UNSIGNED_SHORT_5_6_5:return e.UNSIGNED_SHORT_5_6_5}},isPacked:function(_){return _===e.UNSIGNED_INT_24_8||_===e.UNSIGNED_SHORT_4_4_4_4||_===e.UNSIGNED_SHORT_5_5_5_1||_===e.UNSIGNED_SHORT_5_6_5},sizeInBytes:function(_){switch(_){case e.UNSIGNED_BYTE:return 1;case e.UNSIGNED_SHORT:case e.UNSIGNED_SHORT_4_4_4_4:case e.UNSIGNED_SHORT_5_5_5_1:case e.UNSIGNED_SHORT_5_6_5:case e.HALF_FLOAT:return 2;case e.UNSIGNED_INT:case e.FLOAT:case e.UNSIGNED_INT_24_8:return 4}},validate:function(_){return _===e.UNSIGNED_BYTE||_===e.UNSIGNED_SHORT||_===e.UNSIGNED_INT||_===e.FLOAT||_===e.HALF_FLOAT||_===e.UNSIGNED_INT_24_8||_===e.UNSIGNED_SHORT_4_4_4_4||_===e.UNSIGNED_SHORT_5_5_5_1||_===e.UNSIGNED_SHORT_5_6_5}},T=Object.freeze(e),O={DEPTH_COMPONENT:A.WebGLConstants.DEPTH_COMPONENT,DEPTH_STENCIL:A.WebGLConstants.DEPTH_STENCIL,ALPHA:A.WebGLConstants.ALPHA,RGB:A.WebGLConstants.RGB,RGBA:A.WebGLConstants.RGBA,LUMINANCE:A.WebGLConstants.LUMINANCE,LUMINANCE_ALPHA:A.WebGLConstants.LUMINANCE_ALPHA,RGB_DXT1:A.WebGLConstants.COMPRESSED_RGB_S3TC_DXT1_EXT,RGBA_DXT1:A.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT1_EXT,RGBA_DXT3:A.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT3_EXT,RGBA_DXT5:A.WebGLConstants.COMPRESSED_RGBA_S3TC_DXT5_EXT,RGB_PVRTC_4BPPV1:A.WebGLConstants.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,RGB_PVRTC_2BPPV1:A.WebGLConstants.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,RGBA_PVRTC_4BPPV1:A.WebGLConstants.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,RGBA_PVRTC_2BPPV1:A.WebGLConstants.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,RGBA_ASTC:A.WebGLConstants.COMPRESSED_RGBA_ASTC_4x4_WEBGL,RGB_ETC1:A.WebGLConstants.COMPRESSED_RGB_ETC1_WEBGL,RGB8_ETC2:A.WebGLConstants.COMPRESSED_RGB8_ETC2,RGBA8_ETC2_EAC:A.WebGLConstants.COMPRESSED_RGBA8_ETC2_EAC,RGBA_BC7:A.WebGLConstants.COMPRESSED_RGBA_BPTC_UNORM,componentsLength:function(_){switch(_){case O.RGB:return 3;case O.RGBA:return 4;case O.LUMINANCE_ALPHA:return 2;case O.ALPHA:case O.LUMINANCE:default:return 1}},validate:function(_){return _===O.DEPTH_COMPONENT||_===O.DEPTH_STENCIL||_===O.ALPHA||_===O.RGB||_===O.RGBA||_===O.LUMINANCE||_===O.LUMINANCE_ALPHA||_===O.RGB_DXT1||_===O.RGBA_DXT1||_===O.RGBA_DXT3||_===O.RGBA_DXT5||_===O.RGB_PVRTC_4BPPV1||_===O.RGB_PVRTC_2BPPV1||_===O.RGBA_PVRTC_4BPPV1||_===O.RGBA_PVRTC_2BPPV1||_===O.RGBA_ASTC||_===O.RGB_ETC1||_===O.RGB8_ETC2||_===O.RGBA8_ETC2_EAC||_===O.RGBA_BC7},isColorFormat:function(_){return _===O.ALPHA||_===O.RGB||_===O.RGBA||_===O.LUMINANCE||_===O.LUMINANCE_ALPHA},isDepthFormat:function(_){return _===O.DEPTH_COMPONENT||_===O.DEPTH_STENCIL},isCompressedFormat:function(_){return _===O.RGB_DXT1||_===O.RGBA_DXT1||_===O.RGBA_DXT3||_===O.RGBA_DXT5||_===O.RGB_PVRTC_4BPPV1||_===O.RGB_PVRTC_2BPPV1||_===O.RGBA_PVRTC_4BPPV1||_===O.RGBA_PVRTC_2BPPV1||_===O.RGBA_ASTC||_===O.RGB_ETC1||_===O.RGB8_ETC2||_===O.RGBA8_ETC2_EAC||_===O.RGBA_BC7},isDXTFormat:function(_){return _===O.RGB_DXT1||_===O.RGBA_DXT1||_===O.RGBA_DXT3||_===O.RGBA_DXT5},isPVRTCFormat:function(_){return _===O.RGB_PVRTC_4BPPV1||_===O.RGB_PVRTC_2BPPV1||_===O.RGBA_PVRTC_4BPPV1||_===O.RGBA_PVRTC_2BPPV1},isASTCFormat:function(_){return _===O.RGBA_ASTC},isETC1Format:function(_){return _===O.RGB_ETC1},isETC2Format:function(_){return _===O.RGB8_ETC2||_===O.RGBA8_ETC2_EAC},isBC7Format:function(_){return _===O.RGBA_BC7},compressedTextureSizeInBytes:function(_,R,A){switch(_){case O.RGB_DXT1:case O.RGBA_DXT1:case O.RGB_ETC1:case O.RGB8_ETC2:return Math.floor((R+3)/4)*Math.floor((A+3)/4)*8;case O.RGBA_DXT3:case O.RGBA_DXT5:case O.RGBA_ASTC:case O.RGBA8_ETC2_EAC:return Math.floor((R+3)/4)*Math.floor((A+3)/4)*16;case O.RGB_PVRTC_4BPPV1:case O.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(R,8)*Math.max(A,8)*4+7)/8);case O.RGB_PVRTC_2BPPV1:case O.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(R,16)*Math.max(A,8)*2+7)/8);case O.RGBA_BC7:return Math.ceil(R/4)*Math.ceil(A/4)*16;default:return 0}},textureSizeInBytes:function(_,R,A,t){var e=O.componentsLength(_);return T.isPacked(R)&&(e=1),e*T.sizeInBytes(R)*A*t},alignmentInBytes:function(_,R,A){var t=O.textureSizeInBytes(_,R,A,1)%4;return 0===t?4:2===t?2:1},createTypedArray:function(_,R,A,t){var e=T.sizeInBytes(R);return new(e===Uint8Array.BYTES_PER_ELEMENT?Uint8Array:e===Uint16Array.BYTES_PER_ELEMENT?Uint16Array:e===Float32Array.BYTES_PER_ELEMENT&&R===T.FLOAT?Float32Array:Uint32Array)(O.componentsLength(_)*A*t)},flipY:function(_,R,A,t,e){if(1===e)return _;for(var T=O.createTypedArray(R,A,t,e),n=O.componentsLength(R),B=t*n,G=0;G>O,K=R.pixelHeight>>O,r=C*K*n.componentsLength(e),F=0;F0&&r>0&&F>0))throw C.close(),C.delete(),new R.RuntimeError("Invalid KTX2 file");var s=t.dataFormatDescriptor[0],i=T.transcoder_texture_format;if(163===s.colorModel)if(e.etc)G=N?n.RGBA8_ETC2_EAC:n.RGB8_ETC2,M=N?i.cTFETC2_RGBA:i.cTFETC1_RGB;else if(e.etc1&&!N)G=n.RGB_ETC1,M=i.cTFETC1_RGB;else if(e.s3tc)G=N?n.RGBA_DXT5:n.RGB_DXT1,M=N?i.cTFBC3_RGBA:i.cTFBC1_RGB;else if(e.pvrtc)G=N?n.RGBA_PVRTC_4BPPV1:n.RGB_PVRTC_4BPPV1,M=N?i.cTFPVRTC1_4_RGBA:i.cTFPVRTC1_4_RGB;else if(e.astc)G=n.RGBA_ASTC,M=i.cTFASTC_4x4_RGBA;else{if(!e.bc7)throw new R.RuntimeError("No transcoding format target available for ETC1S compressed ktx2.");G=n.RGBA_BC7,M=i.cTFBC7_RGBA}else if(166===s.colorModel)if(e.astc)G=n.RGBA_ASTC,M=i.cTFASTC_4x4_RGBA;else if(e.bc7)G=n.RGBA_BC7,M=i.cTFBC7_RGBA;else if(e.s3tc)G=N?n.RGBA_DXT5:n.RGB_DXT1,M=N?i.cTFBC3_RGBA:i.cTFBC1_RGB;else if(e.etc)G=N?n.RGBA8_ETC2_EAC:n.RGB8_ETC2,M=N?i.cTFETC2_RGBA:i.cTFETC1_RGB;else if(e.etc1&&!N)G=n.RGB_ETC1,M=i.cTFETC1_RGB;else{if(!e.pvrtc)throw new R.RuntimeError("No transcoding format target available for UASTC compressed ktx2.");G=N?n.RGBA_PVRTC_4BPPV1:n.RGB_PVRTC_4BPPV1,M=N?i.cTFPVRTC1_4_RGBA:i.cTFPVRTC1_4_RGB}if(!C.startTranscoding())throw C.close(),C.delete(),new R.RuntimeError("startTranscoding() failed");for(var S=0;S>S,r=t.pixelHeight>>S;var a=C.getImageTranscodedSizeInBytes(S,0,0,M.value),U=new Uint8Array(a),o=C.transcodeImage(U,S,0,0,M.value,0,-1,-1);if(!_.defined(o))throw new R.RuntimeError("transcodeImage() failed.");O.push(U.buffer),V[E[0]]={internalFormat:G,width:K,height:r,levelBuffer:U}}C.close(),C.delete()}(O,e,M,o,t,K),K}function P(_){(o=_).initializeBasis(),self.onmessage=t(L),self.postMessage(!0)}return function(R){var A=R.data.webAssemblyConfig;if(_.defined(A))return require([A.modulePath],(function(R){if(!_.defined(A.wasmBinaryFile))return R().then((function(_){P(_)}));_.defined(R)||(R=self.MSC_TRANSCODER),R(A).then((function(_){P(_)}))}))}}));