import{A as D,R as At,L as yt,I as pt,_ as Ct,a as T,F as w,T as H,C as g}from"./Viewer-DVCEMRp5.js";import{C as Ft}from"./cubemapToSphericalPolynomial-DI79UW0r.js";import"./vuetify-Ce4WN_Dg.js";import"./overlayscrollbars-CiKU261J.js";import"./index-Bku7SJna.js";import"./echarts-DzoUeqWp.js";import"./codemirror-ZSHHXwGs.js";D.prototype._partialLoadFile=function(F,n,e,r,o=null){const i=t=>{e[n]=t,e._internalCount++,e._internalCount===6&&r(e)},u=(t,l)=>{o&&t&&o(t.status+" "+t.statusText,l)};this._loadFile(F,i,void 0,void 0,!0,u)};D.prototype._cascadeLoadFiles=function(F,n,e,r=null){const o=[];o._internalCount=0;for(let i=0;i<6;i++)this._partialLoadFile(e[i],i,o,n,r)};D.prototype._cascadeLoadImgs=function(F,n,e,r,o=null,i){const u=[];u._internalCount=0;for(let t=0;t<6;t++)this._partialLoadImg(r[t],t,u,F,n,e,o,i)};D.prototype._partialLoadImg=function(F,n,e,r,o,i,u=null,t){const l=At();yt(F,c=>{e[n]=c,e._internalCount++,r&&r.removePendingData(l),e._internalCount===6&&i&&i(o,e)},(c,f)=>{r&&r.removePendingData(l),u&&u(c,f)},r?r.offlineProvider:null,t),r&&r.addPendingData(l)};D.prototype.createCubeTextureBase=function(F,n,e,r,o=null,i=null,u,t=null,l=!1,a=0,s=0,c=null,f=null,G=null,y=!1,p=null){const A=c||new pt(this,7);A.isCube=!0,A.url=F,A.generateMipMaps=!r,A._lodGenerationScale=a,A._lodGenerationOffset=s,A._useSRGBBuffer=!!y&&this._caps.supportSRGBBuffers&&(this.version>1||this.isWebGPU||!!r),A!==c&&(A.label=F.substring(0,60)),this._doNotHandleContextLost||(A._extension=t,A._files=e,A._buffer=p);const _=F;this._transformTextureUrl&&!c&&(F=this._transformTextureUrl(F));const B=F.split("?")[0],P=B.lastIndexOf("."),L=t||(P>-1?B.substring(P).toLowerCase():""),O=Ct(L),k=(d,h)=>{F===_?i&&d&&i(d.status+" "+d.statusText,h):(T.Warn("Failed to load ".concat(F,", falling back to the ").concat(_)),this.createCubeTextureBase(_,n,e,!!r,o,i,u,t,l,a,s,A,f,G,y,p))};if(O)O.then(d=>{const h=R=>{f&&f(A,R),d.loadCubeData(R,A,l,o,i)};p?h(p):e&&e.length===6?d.supportCascades?this._cascadeLoadFiles(n,R=>h(R.map(X=>new Uint8Array(X))),e,i):i?i("Textures type does not support cascades."):T.Warn("Texture loader does not support cascades."):this._loadFile(F,R=>h(new Uint8Array(R)),void 0,void 0,!0,k)});else{if(!e||e.length===0)throw new Error("Cannot load cubemap because files were not defined, or the correct loader was not found.");this._cascadeLoadImgs(n,A,(d,h)=>{G&&G(d,h)},e,i)}return this._internalTexturesCache.push(A),A};const dt=542327876,Q=131072,V=512,Y=4,Z=64,S=131072;function N(F){return F.charCodeAt(0)+(F.charCodeAt(1)<<8)+(F.charCodeAt(2)<<16)+(F.charCodeAt(3)<<24)}function _t(F){return String.fromCharCode(F&255,F>>8&255,F>>16&255,F>>24&255)}const q=N("DXT1"),tt=N("DXT3"),et=N("DXT5"),$=N("DX10"),rt=113,at=116,nt=2,st=10,Gt=88,j=31,mt=0,ht=1,ot=2,ft=3,v=4,it=7,J=20,lt=21,bt=22,Bt=23,xt=24,Rt=25,Ot=26,Ut=28,wt=32;class C{static GetDDSInfo(n){const e=new Int32Array(n.buffer,n.byteOffset,j),r=new Int32Array(n.buffer,n.byteOffset,j+4);let o=1;e[ot]&Q&&(o=Math.max(1,e[it]));const i=e[lt],u=i===$?r[wt]:0;let t=0;switch(i){case rt:t=2;break;case at:t=1;break;case $:if(u===st){t=2;break}if(u===nt){t=1;break}}return{width:e[v],height:e[ft],mipmapCount:o,isFourCC:(e[J]&Y)===Y,isRGB:(e[J]&Z)===Z,isLuminance:(e[J]&S)===S,isCube:(e[Ut]&V)===V,isCompressed:i===q||i===tt||i===et,dxgiFormat:u,textureType:t}}static _GetHalfFloatAsFloatRGBAArrayBuffer(n,e,r,o,i,u){const t=new Float32Array(o),l=new Uint16Array(i,r);let a=0;for(let s=0;s>8)}static _GetRGBArrayBuffer(n,e,r,o,i,u,t,l){const a=new Uint8Array(o),s=new Uint8Array(i,r);let c=0;for(let f=0;f0?o.sphericalPolynomial=Ft.ConvertCubeMapToSphericalPolynomial({size:f[v],right:s[0],left:s[1],up:s[2],down:s[3],front:s[4],back:s[5],format:5,type:1,gammaSpace:!1}):o.sphericalPolynomial=void 0}}C.StoreLODInAlphaChannel=!1;export{C as DDSTools};