From 801bacb9c3898b2a30faa4d0a5435b8318592e9a Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Tue, 15 Oct 2024 22:01:10 +0000 Subject: [PATCH] deploy: 162085b3abba9467a6775b166e02637cec24122f --- CNAME | 1 + assets/{howler-1d21b928.js => howler-1fccfb1e.js} | 2 +- assets/{index-ffc117e4.js => index-3c339844.js} | 4 ++-- index.html | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 CNAME rename assets/{howler-1d21b928.js => howler-1fccfb1e.js} (99%) rename assets/{index-ffc117e4.js => index-3c339844.js} (99%) diff --git a/CNAME b/CNAME new file mode 100644 index 00000000..2c19b6d8 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +studio.m3org.com diff --git a/assets/howler-1d21b928.js b/assets/howler-1fccfb1e.js similarity index 99% rename from assets/howler-1d21b928.js rename to assets/howler-1fccfb1e.js index f10120b7..be9624c1 100644 --- a/assets/howler-1d21b928.js +++ b/assets/howler-1fccfb1e.js @@ -1,4 +1,4 @@ -import{g as L,c as S}from"./index-ffc117e4.js";function D(b,g){for(var r=0;ru[i]})}}}return Object.freeze(Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}))}var O={};/*! +import{g as L,c as S}from"./index-3c339844.js";function D(b,g){for(var r=0;ru[i]})}}}return Object.freeze(Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}))}var O={};/*! * howler.js v2.2.3 * howlerjs.com * diff --git a/assets/index-ffc117e4.js b/assets/index-3c339844.js similarity index 99% rename from assets/index-ffc117e4.js rename to assets/index-3c339844.js index 8e67188a..3d359b2a 100644 --- a/assets/index-ffc117e4.js +++ b/assets/index-3c339844.js @@ -4209,7 +4209,7 @@ void main() { texel.rgb = pow(texel.rgb, vec3(1.0 / 2.2)); gl_FragColor = texel; } - `})}}const Nw=4096,rp=new Z;class tfe{constructor(e,t,r){const i=new vg({preserveDrawingBuffer:!0,antialias:!1,alpha:!0});this.pixelSize=r,this.domElement=i.domElement;const s=new $e(Nw,Nw);i.setClearColor(0,0),i.outputEncoding=cs,i.setSize(s.x,s.y),i.setPixelRatio(window.devicePixelRatio);let o=s.clone().divideScalar(r);o.x|=0,o.y|=0;const a=new Zue(i);a.addPass(new Jue(e,t)),this._renderPixelPass=new que(o,e,t),this._pixelPass=new efe(o),a.addPass(this._renderPixelPass),a.addPass(this._pixelPass),this.renderer=i,this.composer=a}setSize(e,t){let i=new $e(e,t).clone().divideScalar(this.pixelSize);i.x|=0,i.y|=0,this.renderer.setSize(e,t),this._renderPixelPass.setResolution(i),this._pixelPass.setResolution(i)}setPixelSize(e){this.pixelSize=e}render(){this.composer.render()}}class nfe{constructor(e,t){this.renderer=new vg({preserveDrawingBuffer:!0,antialias:!0,alpha:!0}),this.renderer.setClearAlpha(0),this.renderer.premultipliedAlpha=!1,this.scene=t,this.characterManager=e,this.renderer.outputEncoding=pt,this.renderer.setSize(Nw,Nw),this.camera=new Fr(30,1,.1,1e3),this.textureLoader=new lu,this.sceneBackground=new Qe(.1,.1,.1),this.sceneBackgroundAlpha=1,this.frameOffset={min:.2,max:.2},this.usesBackgroundImage=!1,this.backgroundMaterial=new Ei({color:16777215,transparent:!0,opacity:.5});const r=new ou(1e3,1e3),i=new xn(r,this.backgroundMaterial);i.renderOrder=-1,this.backgroundPlane=i,this.pixelRenderer=new tfe(t,this.camera,20),this.boneOffsets={head:null,neck:null,chest:null,hips:null,spine:null,leftUpperLeg:null,leftLowerLeg:null,leftFoot:null,rightUpperLeg:null,rightLowerLeg:null,rightFoot:null}}setScene(e){this.scene=e}setupCamera(e,t,r=30){this.camera.position.copy(e),this.camera.lookAt(t),this.camera.fov=r}_getCharacterMinMax(){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY;return this.characterManager.characterModel.traverse(r=>{r.geometry&&(r.geometry.computeBoundingBox(),r.geometry.boundingBox&&(r.geometry.boundingBox.applyMatrix4(r.matrixWorld),r.geometry.boundingBox.min.yt&&(t=r.geometry.boundingBox.max.y)))}),{minY:e,maxY:t}}frameCloseupShot(){this.frameShot("head","head")}frameMediumShot(){this.frameShot("chest","head")}frameCowboyShot(){this.frameShot("hips","head")}frameFullShot(){this.frameShot("leftFoot","head")}frameShot(e,t,r=null,i=!1,s=!0){const o=this._getBoneWorldPositionWithOffset(e,i),a=this._getBoneWorldPositionWithOffset(t,s);o.y-=this.frameOffset.max,a.y+=this.frameOffset.min,r=r||new Z(0,0,0),this.positionCameraBetweenPoints(o,a,r)}setBottomFrameOffset(e){this.frameOffset.min=e}setTopFrameOffset(e){this.frameOffset.max=e}async calculateBoneOffsets(e){for(const t in this.boneOffsets){const r=await this._getMinMaxOffsetByBone(this.characterManager.characterModel,t,e);this.boneOffsets[t]=r}}_getBoneWorldPositionWithOffset(e,t){const r=this._getFirstBoneWithName(e);if(!r||!this.boneOffsets[e])return new Z;const i=new Z;r.getWorldPosition(i);const s=t?this.boneOffsets[e].max:this.boneOffsets[e].min;return i.y+=s.y,i}_getBoneWorldPosition(e){const t=this._getFirstBoneWithName(e);return t!=null?new Z().setFromMatrixPosition(t.matrixWorld):(console.warn(`Bone with name '${e}' not found in one of the skinned meshes.`),new Z(0,0,0))}_getFirstBoneWithName(e){let t=null;return this.characterManager.characterModel.traverse(r=>{if(r instanceof Al){if(!r.geometry){console.error("Invalid skinned mesh found in children.");return}const i=r.skeleton.bones.findIndex(s=>s.name===e);if(i!==-1){t=r.skeleton.bones[i];return}}}),t}setCameraFrameWithName(e,t){switch(e.toLowerCase()){case"fullshot":this.frameShot("leftFoot","head",t);break;case"cowboyshot":this.frameShot("hips","head",t);break;case"mediumshot":this.frameShot("chest","head",t);break;case"mediumcloseup":case"mediumcloseupshot":this.frameShot("chest","head",t,!0);break;case"closeup":case"closeupshot":this.frameShot("head","head",t);break;default:console.warn("unkown cameraFrame: "+e+". Please use fullShot, cowboyShot, mediumShot, mediumCloseup or closeup"),this.frameShot("leftFoot","head",t);break}}async _getMinMaxOffsetByBone(e,t,r){return new Promise(async(i,s)=>{(!e||!e.traverse)&&(console.error("Invalid parent object provided."),s(null));const o=new Z(1/0,1/0,1/0),a=new Z(-1/0,-1/0,-1/0),l=[];e.traverse(async u=>{u instanceof Al&&(l.push(this._saveBonesPos(u.skeleton)),u.skeleton.pose())});let A=0;await(u=>new Promise(f=>setTimeout(f,u)))(10),e.traverse(u=>{if(u instanceof Al){if(!u.geometry){console.error("Invalid skinned mesh found in children.");return}const f=u.skeleton.bones.findIndex(g=>g.name===t);if(f===-1){console.error(`Bone with name '${t}' not found in one of the skinned meshes.`);return}const h=u.geometry.getAttribute("position"),p=u.geometry.getAttribute("skinWeight"),d=u.geometry.getAttribute("skinIndex");for(let g=0;g=r){const x=u.skeleton.bones[f],_=new Z().setFromMatrixPosition(x.matrixWorld),C=m.clone().sub(_);o.min(C),a.max(C)}}this._restoreSavedPose(l[A],u.skeleton),A++}}),i({min:o,max:a})})}_saveBonesPos(e){let t=[];return e.bones.forEach(r=>{t.push({position:r.position.clone(),rotation:r.rotation.clone(),scale:r.scale.clone()})}),t}_restoreSavedPose(e,t){e&&t.bones.forEach((r,i)=>{r.position.copy(e[i].position),r.rotation.copy(e[i].rotation),r.scale.copy(e[i].scale)})}positionCameraBetweenPoints(e,t,r,i=30){const s=new ps;s.expandByPoint(e),s.expandByPoint(t),this.camera.fov=i;const o=this.camera.fov*(Math.PI/180),l=s.getSize(new Z).length()/(2*Math.tan(o/2));s.getCenter(rp),this.camera.position.copy(rp),r.y*=.5,this.camera.lookAt(rp.clone().sub(r));const A=new Z;this.camera.getWorldDirection(A),this.camera.position.addScaledVector(A,-l),this.camera.updateProjectionMatrix()}setCamera(e,t,r=30){this.camera.position.copy(e),this.camera.fov=r,rp.set(0,0,-1),this.cameraDir=rp.applyQuaternion(this.camera.quaternion),this.cameraDir.normalize(),this.camera.position.x-=this.cameraDir.x*t,this.camera.position.z-=this.cameraDir.z*t}setBackground(e){if(Array.isArray(e)){const t=e[3]==null?1:e[3];this.setBackgroundColor(e[0],e[1],e[2],t)}else this.setBackgroundImage(e)}setBackgroundColor(e,t,r,i){const s=new Qe(e,t,r,i);this.sceneBackground=s,i==null&&(i=1),i>1&&(i=1),i<0&&(i=0),this.sceneBackgroundAlpha=i,this.backgroundMaterial.color=s,this.usesBackgroundImage=!1}setBackgroundImage(e){return new Promise(async(t,r)=>{try{const i=await this.texureLoader.load(e);i&&(i.wrapS=i.wrapT=As,this.sceneBackground=i,this.usesBackgroundImage=!0,this.sceneBackgroundAlpha=1,t())}catch(i){console.error("Error loading background image: ",i),r(i)}})}_setBackground(){if(this.usesBackgroundImage==!1&&this.sceneBackgroundAlpha!=1)if(this.sceneBackgroundAlpha==0)this.scene.background=null;else{this.scene.background=null,this.scene.add(this.backgroundPlane),this.backgroundPlane.position.copy(this.camera.position);var e=new Z(0,0,-1);e.applyQuaternion(this.camera.quaternion);var t=100;this.backgroundPlane.position.addScaledVector(e,t),this.backgroundPlane.lookAt(this.camera.position)}else this.scene.background=this.sceneBackground}_restoreBackground(){this.scene.background=null,this.usesBackgroundImage==!1&&this.sceneBackgroundAlpha!=1&&this.scene.remove(this.backgroundPlane)}getImageData(e,t,r=null){return this._createImage(e,t,r).split("base64,")[1]}_createImage(e,t,r=null){const i=e/t;typeof r=="number"&&this.pixelRenderer.setPixelSize(r),this.renderer.setSize(e,t),this.pixelRenderer.setSize(e,t);const s="image/png";this.camera.aspect=i,this.camera.updateProjectionMatrix();const o=typeof r=="number"?this.pixelRenderer:this.renderer;try{this._setBackground(),o.render(this.scene,this.camera);let a=o.domElement.toDataURL(s);return this._restoreBackground(),a}catch(a){return console.error(a),null}}savePixelScreenshot(e,t,r,i){this.pixelRenderer.setPixelSize(i),this.pixelRenderer.setSize(t,r);const s=this._createImage(t,r,!0),o="image/octet-stream",a="image/png";this.saveFile(s.replace(a,o),e+".png")}saveScreenshot(e,t,r){const i=this._createImage(t,r),s="image/octet-stream",o="image/png";this.saveFile(i.replace(o,s),e+".png")}getScreenshotImage(e,t){const r=this._createImage(e,t),i=new Image;return i.src=r,i}getScreenshotTexture(e,t){const r=this.getScreenshotImage(e,t),i=new Qn(r);return i.needsUpdate=!0,i}getScreenshotBlob(e,t){const r=this._createImage(e,t),i=t6.Buffer.from(r.replace(/^data:image\/\w+;base64,/,""),"base64");return new Blob([i],{type:"image/jpeg"})}saveFile(e,t){const r=document.createElement("a");typeof r.download=="string"?(document.body.appendChild(r),r.download=t,r.href=e,r.click(),document.body.removeChild(r)):window.open(e,"_blank").document.write(""+t+"")}}const rfe=2;class ife{constructor(e=.5,t=.5,r=1,i=5){this.vrmBlinkers=[],this.mode="ready",this.clock=new OH,this.closeTime=e,this.openTime=t,this.continuity=r,this.randomness=i,this._eyeOpen=1,this._blinkCounter=0,this.isTakingScreenShot=!1,this.update()}addVRM(e){this.vrmBlinkers.push(e)}removeVRM(e){const t=this.vrmBlinkers.indexOf(e);t!==-1&&this.vrmBlinkers.splice(t,1)}enableScreenshot(){this.isTakingScreenShot=!0,this._eyeOpen=rfe,this._updateBlinkers()}disableScreenshot(){this.isTakingScreenShot=!1}update(){setInterval(()=>{if(this.isTakingScreenShot)return;const e=this.clock.getDelta();switch(this.mode){case"closing":this._eyeOpen>0?this._eyeOpen-=e/this.closeTime:(this._eyeOpen=0,this.mode="open"),this._updateBlinkers();break;case"open":this._eyeOpen<1?this._eyeOpen+=e/this.openTime:(this._eyeOpen=1,this.mode="ready"),this._updateBlinkers();break;case"ready":this._blinkCounter+=e,this._blinkCounter>=this.continuity&&(Math.floor(Math.random()*this.randomness)===0&&(this.mode="closing"),this._blinkCounter=0);break}},1e3/30)}_updateBlinkers(){this.vrmBlinkers.forEach(e=>{e.expressionManager.setValue(oi.Blink,1-this._eyeOpen),e.expressionManager.update()})}}function E5(){return(E5=Object.assign||function(n){for(var e=1;e0?u+s.byteLength:0;f%8&&(f+=8-f%8);let h=[],p=new DataView(new ArrayBuffer(24*n.levels.length)),d=(f||u+s.byteLength)+t.byteLength;for(let y=0;y0?f:0),!0),m.setBigUint64(60,BigInt(t.byteLength),!0),new Uint8Array(sp([new Uint8Array(Tr).buffer,g,p.buffer,a,s,new ArrayBuffer(f>0?f-(u+s.byteLength):0),t,...h]))}var VC,jC,ufe={enableDebug:!1,isUASTC:!0,isKTX2File:!0,isInputSRGB:!0,generateMipmap:!0,needSupercompression:!0,isSetKTX2SRGBTransferFunc:!0},WC=new OffscreenCanvas(128,128),j3=WC.getContext("2d",{willReadFrequently:!0}),C5=typeof document>"u";function ffe(n){return createImageBitmap(n).then(function(e){return WC.width=e.width,WC.height=e.height,j3.drawImage(e,0,0),j3.getImageData(0,0,e.width,e.height)})}function hfe(n,e){return e===void 0&&(e={}),pfe().then(function(t){var r=new t.BasisEncoder;return dfe(e,r),r.setTexType(VC.cBASISTexType2D),ofe(n,ArrayBuffer)&&(n=new Blob([n])),ffe(n).then(function(i){r.setSliceSourceImage(0,new Uint8Array(i.data),i.width,i.height,jC.RAW);var s=new Uint8Array(10485760),o=r.encode(s);if(o===0)throw"encode failed";var a=new Uint8Array(s.buffer,0,o),l=lfe(s);if(e.kvData){for(var A in e.kvData)l.keyValue[A]=e.kvData[A];a=cfe(l,{keepWriter:!0})}return a})})}function dfe(n,e){n===void 0&&(n={}),(n=sfe({},ufe,n)).enableDebug!==void 0&&e.setDebug(n.enableDebug),n.isUASTC!==void 0&&e.setUASTC(n.isUASTC),n.isKTX2File!==void 0&&e.setCreateKTX2File(n.isKTX2File),n.isSetKTX2SRGBTransferFunc!==void 0&&e.setKTX2SRGBTransferFunc(n.isSetKTX2SRGBTransferFunc),n.generateMipmap!==void 0&&e.setMipGen(n.generateMipmap),n.isYFlip!==void 0&&e.setYFlip(n.isYFlip),n.qualityLevel!==void 0&&e.setQualityLevel(n.qualityLevel),n.compressionLevel!==void 0&&e.setCompressionLevel(n.compressionLevel),n.needSupercompression!==void 0&&e.setKTX2UASTCSupercompression(n.needSupercompression),n.isNormalMap!==void 0&&e.setNormalMap(n.isNormalMap)}var lB=null;function pfe(){return lB||(lB=new Promise(function(n,e){C5?(importScripts("https://mdn.alipayobjects.com/rms/afts/file/A*SrRkQarYYl4AAAAAAAAAAAAAARQnAQ/basis_encoder.js"),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qFWbTrA0hZYAAAAAAAAAAAAAARQnAQ/basis_encoder.wasm").then(function(t){return t.arrayBuffer()}).then(function(t){BASIS({wasmBinary:t}).then(function(r){r.initializeBasis(),n(r)}).catch(e)}).catch(e)):Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*SrRkQarYYl4AAAAAAAAAAAAAARQnAQ/basis_encoder.js").then(function(t){return t.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qFWbTrA0hZYAAAAAAAAAAAAAARQnAQ/basis_encoder.wasm").then(function(t){return t.arrayBuffer()})]).then(function(t){var r=t[0],i=t[1],s=document.createElement("script");s.onload=function(){BASIS({wasmBinary:i}).then(function(o){o.initializeBasis(),n(o)}).catch(e)},s.src=URL.createObjectURL(new Blob([r])),s.onerror=e,document.body.appendChild(s)}).catch(e)})),lB}C5&&self.addEventListener("message",function(n){hfe(n.data).then(function(e){self.postMessage(e)}).catch(function(e){self.postMessage({error:e})})});class mfe{constructor(e,t){if(this.gl=e,this.libktx=null,e!==void 0)if(t===void 0&&LIBKTX!==void 0&&(t=LIBKTX),t!==void 0)this.initializied=this.init(e,t);else{console.error("Failed to initalize KTXDecoder: ktx library undefined");return}else{console.error("Failed to initalize KTXDecoder: WebGL context undefined");return}}async init(e,t){this.libktx=await t({preinitializedWebGLContext:e}),this.libktx.GL.makeContextCurrent(this.libktx.GL.createContext(e.canvas,{majorVersion:2}))}stringToUastcFlags(e){return e==="FASTER"?this.libktx.UastcFlags.LEVEL_FASTER.value:e==="FASTEST"?this.libktx.UastcFlags.LEVEL_FASTEST.value:e==="SLOWER"?this.libktx.UastcFlags.LEVEL_SLOWER.value:e==="SLOWEST"?this.libktx.UastcFlags.LEVEL_VERYSLOW.value:this.libktx.UastcFlags.LEVEL_DEFAULT.value}stringToSupercmpScheme(e){return e==="Zstd"?this.libktx.SupercmpScheme.ZSTD:e==="Zlib"?this.libktx.SupercmpScheme.ZLIB:e==="BasisLZ"?this.libktx.SupercmpScheme.BASIS_LZ:this.libktx.SupercmpScheme.NONE}transcodeRGBA(e){if(!e.needsTranscoding)return;const t=this.libktx.TranscodeTarget.RGBA8888;e.transcodeBasis(t,0)!=this.libktx.ErrorCode.SUCCESS&&console.warn("Texture transcode failed. See console for details.")}transcode(e){if(e.gpuFormat="RGBA8888",e.needsTranscoding){let t,r=!1,i=!1,s=!1,o=!1,a=!1;r=!!this.gl.getExtension("WEBGL_compressed_texture_astc"),i=!!this.gl.getExtension("WEBGL_compressed_texture_etc1"),s=!!this.gl.getExtension("WEBGL_compressed_texture_s3tc"),o=!!this.gl.getExtension("EXT_texture_compression_bptc"),a=!!this.gl.getExtension("WEBGL_compressed_texture_pvrtc")||!!this.gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),r?(t=this.libktx.TranscodeTarget.ASTC_4x4_RGBA,e.gpuFormat="ASTC_4x4_RGBA"):o?(t=this.libktx.TranscodeTarget.BC7_RGBA,e.gpuFormat="BC7_RGBA"):s?(t=this.libktx.TranscodeTarget.BC1_OR_3,e.gpuFormat="BC1_OR_3"):a?(t=this.libktx.TranscodeTarget.PVRTC1_4_RGBA,e.gpuFormat="PVRTC1_4_RGBA"):i?(t=this.libktx.TranscodeTarget.ETC,e.gpuFormat="ETC"):(t=this.libktx.TranscodeTarget.RGBA8888,e.gpuFormat="RGBA8888"),e.transcodeBasis(t,0)!=this.libktx.ErrorCode.SUCCESS&&console.warn("Texture transcode failed. See console for details.")}}async loadKtxFromUri(e){await this.initializied;const t=await fetch(e),r=new Uint8Array(await t.arrayBuffer()),i=new this.libktx.ktxTexture(r);this.transcode(i);let s=i.glUpload();if(s.texture==null){console.error("Could not load KTX data");return}return s.texture.levels=Math.log2(i.baseWidth),s.texture.width=i.baseWidth,s.texture.height=i.baseHeight,s.texture.gpuSize=i.dataSize,s.texture.gpuFormat=i.gpuFormat,s.texture.isSRGB=i.isSRGB,s.texture}async loadKtxFromBuffer(e){await this.initializied;const t=new this.libktx.ktxTexture(e);this.transcode(t);const r=t.glUpload();if(r.texture==null){console.error("Could not load KTX data");return}return r.texture.levels=Math.log2(t.baseWidth),r.texture.width=t.baseWidth,r.texture.height=t.baseHeight,r.texture.gpuSize=t.dataSize,r.texture.gpuFormat=t.gpuFormat,r.texture.isSRGB=t.isSRGB,r.texture}async compress(e,t,r,i,s={}){const o=new this.libktx.ktxTexture(e,t,r,i,s.srgb);if(!s.hasOwnProperty("basisu_options")){const A=new this.libktx.ktxBasisParams;A.uastc=!1,A.noSSE=!0,A.verbose=!1,A.qualityLevel=100,A.compressionLevel=2,s.basisu_options=A}s.hasOwnProperty("compression_level")||(s.compression_level=18),s.hasOwnProperty("supercmp_scheme")||(s.supercmp_scheme=this.libktx.SupercmpScheme.NONE),console.log(s);const a=o.compressBasisU(s.basisu_options,s.supercmp_scheme,s.compression_level);return Uint8ClampedArray.from(a)}}class gfe{constructor(){this.ktxEncoder=null,this.libktx=null,this.init()}async init(){const t=document.createElement("canvas").getContext("webgl"),r=new mfe(t,window.LIBKTX);await r.init(t,window.LIBKTX),this.ktxEncoder=r,this.libktx=r.libktx}async compress(e,t,r,i,s={}){const o=await new this.libktx.ktxBasisParams,a=s;return o.uastc=a.uastc!==void 0?a.uastc:!1,o.noSSE=a.noSSE!==void 0?a.noSSE:!1,o.verbose=a.verbose!==void 0?a.verbose:!1,o.normalMap=a.normalMap!==void 0?a.normalMap:!1,o.compressionLevel=a.compressionLevel!==void 0?a.compressionLevel:1,o.qualityLevel=a.qualityLevel!==void 0?a.qualityLevel:60,o.maxEndpoints=a.ETC1SmaxEndpoints!==void 0?a.ETC1SmaxEndpoints:0,o.endpointRDOThreshold=a.ETC1SEndpointRdoThreshold!==void 0?a.ETC1SEndpointRdoThreshold:1.25,o.maxSelectors=a.ETC1SMaxSelectors!==void 0?a.ETC1SMaxSelectors:0,o.selectorRDOThreshold=a.ETC1SSelectorRdoThreshold!==void 0?a.ETC1SSelectorRdoThreshold:1.25,o.noEndpointRDO=a.ETC1SNoEndpointRdo!==void 0?a.ETC1SNoEndpointRdo:!1,o.noSelectorRDO=a.ETC1SNoSelectorRdo!==void 0?a.ETC1SNoSelectorRdo:!1,o.uastcFlags=this.ktxEncoder.stringToUastcFlags(a.uastcFlags),o.uastcRDO=o.uastcRDO!==void 0?o.uastcRDO:!1,o.uastcRDOQualityScalar=a.uastcRDOQualityScalar!==void 0?a.uastcRDOQualityScalar:1,o.uastcRDODictSize=a.uastcRDODictSize!==void 0?a.uastcRDOQualityScalar:4096,o.uastcRDOMaxSmoothBlockErrorScale=a.uastcRDOMaxSmoothBlockErrorScale!==void 0?a.uastcRDOMaxSmoothBlockErrorScale:10,o.uastcRDOMaxSmoothBlockStdDev=a.uastcRDOMaxSmoothBlockStdDev!==void 0?a.uastcRDOMaxSmoothBlockStdDev:18,o.uastcRDODontFavorSimplerModes=a.uastcRDODontFavorSimplerModes!==void 0?a.uastcRDODontFavorSimplerModes:!1,s.basisu_options=o,s.hasOwnProperty("supercmp_scheme")?s.supercmp_scheme=this.ktxEncoder.stringToSupercmpScheme(s.supercmp_scheme):s.supercmp_scheme=this.libktx.SupercmpScheme.NONE,await this.ktxEncoder.compress(e,t,r,i,s)}}var Dn;(function(n){n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.LINEAR=9729]="LINEAR",n[n.REPEAT=10497]="REPEAT"})(Dn||(Dn={}));const KC="blend_",W3="vrmColliderSphere";function vfe(n){var e;return{title:n.name,version:"v0",author:((e=n.authors)==null?void 0:e.length)>0?n.authors.join(", "):"",reference:n.references!=null?n.references.join(", "):"",contactInformation:n.contactInformation!=null?n.contactInformation:"",otherPermissionUrl:n.otherPermissionUrl,allowedUserName:n.avatarPermission!=null?n.avatarPermission:"",violentUssageName:n.allowExcessivelyViolentUsage?"Allow":"Disallow",sexualUssageName:n.allowExcessivelySexualUsage?"Allow":"Disallow",commercialUssageName:n.commercialUsage=="personalProfit"||n.commercialUsage=="corporation"?"Allow":"Disallow",licenseName:n.copyrightInformation,otherLicenseUrl:n.otherLicenseUrl,metaVersion:"0"}}function yfe(n){const e=[];for(const t in n.humanBones)e.push({bone:t,node:n.humanBones[t].node});return{humanBones:e}}function wfe(n){switch(n){case"happy":return"joy";case"sad":return"sorrow";case"relaxed":return"fun";case"aa":return"a";case"ih":return"i";case"ou":return"u";case"ee":return"e";case"oh":return"o";default:return n}}function xfe(n){if(n.includes("Thumb")){if(n.includes("Metacarpal"))return n.replace("Metacarpal","Proximal");if(n.includes("Proximal"))return n.replace("Proximal","Intermediate")}return n}class _fe{async parse(e,t,r,i,s,o,a){var be;const l=vfe(e.meta),A=yfe(e.humanoid),c=e.materials,u=[],f={generator:"UniGLTF-2.0.0",version:"2.0"};if(t)if(A)if(l){if(!c)throw new Error("materials is undefined or null")}else throw new Error("meta is undefined or null");else throw new Error("humanoid is undefined or null");else throw new Error("avatar is undefined or null");const h=c.filter((N,j,se)=>se.findIndex(he=>he.name===N.name.replace(" (Outline)",""))===j).map(N=>N),p=h.map(N=>N.name),d=r?{name:"icon",imageBitmap:r.image}:null,g=h.filter(N=>N.map).map(N=>{if(!N.map)throw new Error(N.name+" map is null");return{name:N.name,imageBitmap:N.map.image}}),m=h.filter(N=>N.userData.shadeTexture).map(N=>{if(!N.userData.shadeTexture)throw new Error(N.userData.shadeTexture+" map is null");return{name:N.name+"_shade",imageBitmap:N.userData.shadeTexture.image}}),y=h.filter(N=>N.roughnessMap).map(N=>N.roughnessMap?{name:N.name+"_orm",imageBitmap:N.roughnessMap.image}:null),w=h.filter(N=>N.roughnessMap).map(N=>N.normalMap?{name:N.name+"_normal",imageBitmap:N.normalMap.image}:null),x=[...g,...m,...y,...w].filter(N=>N!==null),_=Mfe(x,d,s?"image/ktx2":"image/png"),C=Tfe(_),S=Ife(_,s),b=Sfe(h,x),M=t.children.filter(N=>N.children.length>0&&N.children[0].type===li.Bone)[0],D=S5(M).filter(N=>N.name!==W3),$=D.map(N=>N.name),H=D.map(N=>{const j=N.children.filter(se=>se.name!==W3).map(se=>$.indexOf(se.name));return{name:N.name,rotation:[N.quaternion.x,N.quaternion.y,N.quaternion.z,N.quaternion.w],scale:[N.scale.x,N.scale.y,N.scale.z],translation:[N.position.x,N.position.y,N.position.z],children:j.length>0?j:void 0}}),I=[],v=t.children.filter(N=>N.type===li.Group||N.type===li.SkinnedMesh),E=[];v.forEach((N,j)=>{const se=N.type===li.Group?N.children[0]:N,he=se.geometry.attributes,me=new Gl(he.position,Dn.FLOAT,Kt.POSITION,zo.VEC3,se.name,void 0);E.push(me);const G=E.length-1,R=he.normal.array,T=new Float32Array(R.length);for(let ie=0;ieie):[N]).forEach(ie=>{if(!ie.geometry.index)throw new Error(ie.name+" geometry.index is null");E.push(new Gl(ie.geometry.index,Dn.UNSIGNED_INT,Kt.INDEX,zo.SCALAR,se.name,ie.name))}),se.morphTargetDictionary||(se.morphTargetDictionary={},se.morphTargetInfluences=[],se.geometry.morphAttributes={},se.updateMorphTargets()),se.geometry.userData.targetNames=[];const ae=(ie,Te,Me,Le)=>{const ke=[],De=[];for(let fe=0;fe0){const fe=[...ke].sort((Fe,We)=>Fe-We),Ce=[];for(let Fe=0;Fe({mesh:0,index:he.index,weight:he.weight*100}));if(se.length>0){let he=!1;for(const me in oi)if(N===oi[me]&&N!=="surprised"){u.push({name:N,presetName:wfe(N),binds:se,isBinary:j.isBinary}),he=!0;break}he===!1&&u.push({name:N,presetName:"unknown",binds:se,isBinary:j.isBinary})}}v.forEach(N=>{const j=N.type===li.Group?N.children[0]:N,se=new Float32Array(j.skeleton.boneInverses.map(he=>he.elements).flat());E.push(new Gl(new At(se,16),Dn.FLOAT,Kt.BIND_MATRIX,zo.MAT4,j.name,j.name))}),I.push(...E.map(N=>({componentType:N.valueType,count:N.attribute.count,max:N.max,min:N.min,normalized:!1,type:N.accessorsType})));const U=Efe(v,E,p);v.forEach((N,j)=>{H.push({mesh:j,name:N.name,rotation:[N.quaternion.x,N.quaternion.y,N.quaternion.z,N.quaternion.w],scale:[N.scale.x,N.scale.y,N.scale.z],skin:j,translation:[N.position.x,N.position.y,N.position.z]})});const P=Cfe(v,E,$),L={humanBones:[]};A.humanBones.forEach(N=>{$.indexOf(N.node.name)!=-1&&L.humanBones.push({bone:xfe(N.bone),node:$.indexOf(N.node.name),useDefaultValues:!0})});const z={floatProperties:{_DstBlend:.5,_ShadeShift:.5,_ShadeToony:.5,_ShadingGradeRate:.5},keywordMap:{_NORMALMAP:!1,MTOON_OUTLINE_COLOR_FIXED:!0,MTOON_OUTLINE_WIDTH_WORLD:!0},name:"VRMCombinedMat",renderQueue:2e3,shader:"VRM/MToon",tagMap:{RenderType:"Opaque"},textureProperties:{_MainTex:0,_ShadeTexture:0},vectorProperties:{_Color:[1,1,1,1],_EmissionColor:[0,0,0,1],_EmissionMap:[0,0,1,1],_MainTex:[0,0,1,1],_OutlineColor:[0,0,0,1],_OutlineWidthTexture:[0,0,1,1],_ReceiveShadowTexture:[0,0,1,1],_RimColor:[0,0,0,1],_RimTexture:[0,0,1,1],_ShadeColor:[.9,.9,.9,1]}},K={name:"STDCombinedMat",shader:"VRM_USE_GLTFSHADER"},O=[];h.forEach(N=>{N.type=="ShaderMaterial"?O.push(Object.assign({},z)):O.push(Object.assign({},K))});const B=l;i.forEach(N=>{for(let j=0;jN.isSkinnedMesh))==null?void 0:be.skeleton)||null;for(let N=0;N{const me=he.sphere;se.colliders.push({radius:me.radius*o,offset:{x:me.offset[0]*o,y:me.offset[1]*o,z:me.offset[2]*o}})}),W.push(se)}}console.log("COLLIDER GROUPS",W);const F=N=>{for(let j=0;j{var G;const j=F(N.name);if(j===-1){console.warn("Spring bone "+N.name+" was removed during cleanup process. Skipping.");return}const se=[];N.colliderGroups.forEach(R=>{const T=R.colliders[0];if(T!=null){const V=T.parent,te=W.findIndex(ae=>ae.name===V.name);te!=-1&&(se.includes(te)||se.push(te))}});let he=F((G=N.center)==null?void 0:G.name);he==-1&&console.warn("no center bone for spring bone "+N.name);const me=N.settings;X.push({bones:[j],center:he,colliderGroups:se,dragForce:me.dragForce,gravityDir:{x:me.gravityDir.x,y:me.gravityDir.y,z:me.gravityDir.z},gravityPower:me.gravityPower,hitRadius:me.hitRadius,stiffiness:me.stiffness})});const ue={boneGroups:X,colliderGroups:W};console.log(ue),B.texture=d?_.length-1:void 0;const le=await Promise.all(x.map(async N=>({buffer:s?await K3(N.imageBitmap):$3(N.imageBitmap),type:Kt.IMAGE})));E.forEach((N,j)=>{N.buffer?le.push({buffer:N.buffer,typeString:"",type:N.type}):N.sparse&&(le.push({buffer:N.sparse.indices,typeString:"indices",type:N.type,count:N.sparse.count}),le.push({buffer:N.sparse.values,typeString:"values",type:N.type})),le.length-1}),d&&le.push({buffer:s?await K3(d.imageBitmap):$3(d.imageBitmap),type:Kt.IMAGE});let oe=0,re=0,pe=0,_e=0;const Re=le.map(N=>{const j={buffer:0,byteLength:N.buffer.byteLength,byteOffset:oe,target:N.type===Kt.IMAGE||N.type===Kt.BIND_MATRIX||N.typeString==="indices"||N.typeString==="values"?void 0:N.type===Kt.INDEX?Dn.ELEMENT_ARRAY_BUFFER:Dn.ARRAY_BUFFER};return oe+=N.buffer.byteLength,N.type===Kt.IMAGE?(_[re++].bufferView=_e,_e++):E[pe].sparse?(I[pe].sparse==null&&(I[pe].sparse={}),N.typeString==="indices"&&(I[pe].sparse.count=N.count,I[pe].sparse[N.typeString]={bufferView:_e,byteOffset:0,componentType:Dn.UNSIGNED_INT}),N.typeString==="values"&&(I[pe].sparse[N.typeString]={bufferView:_e,byteOffset:0}),N.typeString==="values"&&pe++,_e++):(E[pe].bufferIndex=_e,I[pe].bufferView=_e,pe++,_e++),j}),Q=Rfe(t,H);bfe(B);const de=["KHR_materials_unlit","KHR_texture_transform","VRM"];s&&de.push("KHR_texture_basisu");const Ae={accessors:I,asset:f,buffers:[{byteLength:oe}],bufferViews:Re,extensions:{VRM:{blendShapeMaster:{blendShapeGroups:u},firstPerson:{firstPersonBone:44,firstPersonBoneOffset:new Z,lookAtHorizontalInner:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtHorizontalOuter:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtTypeName:"Bone",lookAtVerticalDown:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtVerticalUp:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10}},materialProperties:O,humanoid:L,meta:B,secondaryAnimation:ue,specVersion:"0.0"}},extensionsUsed:de,images:_,materials:b,meshes:U,nodes:H,samplers:C,scenes:Q,skins:P,textures:S};console.log("output",Ae);const q=new Y3(YC(JSON.stringify(Ae,void 0,2)),"JSON"),J=new Y3(Pp(le.map(N=>N.buffer)),"BIN\0"),ce=Pp([q.buffer,J.buffer]),xe=Pp([YC("glTF"),$C(2,4),$C(ce.byteLength+12,4)]);a(Pp([xe,ce]))}}function bfe(n){n.title=n.title||"Character",n.version=n.version||"1",n.author=n.author||"Anon",n.contactInformation=n.contactInformation||"",n.reference=n.reference||"",n.allowedUserName=n.allowedUserName||"Everyone",n.violentUssageName=n.violentUssageName||"Disallow",n.sexualUssageName=n.sexualUssageName||"Disallow",n.commercialUssageName=n.commercialUssageName||"Disallow",n.otherPermissionUrl=n.otherPermissionUrl||"",n.licenseName=n.licenseName||"Redistribution_Prohibited",n.otherLicenseUrl=n.otherLicenseUrl||""}function S5(n){return n.children.length<=0?[n]:[n].concat(n.children.map(e=>S5(e)).flat())}const Bfe=new gfe;async function K3(n){const e=await createImageBitmap(n),t=document.createElement("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0);const i=r.getImageData(0,0,t.width,t.height),s=new Uint8Array(i.data.buffer);return await Bfe.compress(s,t.width,t.height,4,{normalMap:!1,uastc:!1,qualityLevel:50,compressionLevel:2,uastcFlags:"DEFAULT",compressionUASTC_Rdo_Level:18,uastcRDO:!1,uastcRDOQualityScalar:1,uastcRDODictSize:4096,uastcRDOMaxSmoothBlockErrorScale:10,uastcRDOMaxSmoothBlockStdDev:18,uastcRDODontFavorSimplerModes:!1,ETC1SQualityLevel:128,ETC1SmaxEndpoints:0,ETC1SEndpointRdoThreshold:1.25,ETC1SMaxSelectors:0,ETC1SSelectorRdoThreshold:1.25,ETC1SNoEndpointRdo:!1,ETC1SNoSelectorRdo:!1,supercmp_scheme:"Zstd"})}function $3(n){const e=document.createElement("canvas");e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0);const t=e.toDataURL("image/png"),r=atob(t.split(",")[1]),i=(4-r.length%4)%4,s=new ArrayBuffer(r.length+i),o=new DataView(s);for(let a=0;a4?A=r[a*n.itemSize+l]:l===0?A=n.getX(a):l===1?A=n.getY(a):l===2?A=n.getZ(a):A=n.getW(a),e===Dn.UNSIGNED_SHORT?o.setUint16(i,A,!0):e===Dn.UNSIGNED_INT?o.setUint32(i,A,!0):o.setFloat32(i,A,!0),i+=t}return s}class Y3{constructor(e,t){this.data=e,this.type=t;const r=this.padBuffer(this.data,t==="JSON"?32:0);this.buffer=Pp([$C(r.byteLength,4),YC(this.type),r])}padBuffer(e,t){const r=Math.ceil(e.byteLength/4)*4;if(e.byteLength===r)return e;const i=new ArrayBuffer(r);return new Uint8Array(i).set(new Uint8Array(e)),new Uint8Array(i).fill(t,e.byteLength),i}}const X3=n=>{const e=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],t=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY];for(let r=0;rn.map(r=>{const i=r.type===li.Group?r.children[0]:r,s=r.type===li.Group?r.children.map(o=>o):[r];return{name:r.name,primitives:s.map(o=>{const a=e.map(A=>A.meshName===i.name?A.type:null),l=Array.isArray(o.material)?o.material[0].name:o.material.name;return{attributes:{JOINTS_0:a.indexOf(Kt.SKIN_INDEX),NORMAL:a.indexOf(Kt.NORMAL),POSITION:a.indexOf(Kt.POSITION),TEXCOORD_0:a.indexOf(Kt.UV),WEIGHTS_0:a.indexOf(Kt.SKIN_WEIGHT)},extras:{targetNames:o.geometry.userData.targetNames},indices:e.map(A=>A.type===Kt.INDEX&&A.meshName===i.name?A.name:null).indexOf(o.name),material:t.indexOf(l),mode:4,targets:i.geometry.userData.targetNames?i.geometry.userData.targetNames.map(A=>{const c=e.map(h=>h.type===Kt.BLEND_NORMAL&&h.meshName===i.name?h.name:null).indexOf(KC+A),u=e.map(h=>h.type===Kt.BLEND_POSITION&&h.meshName===i.name?h.name:null).indexOf(KC+A),f={};return u!==-1&&(f.POSITION=u),c!==-1&&(f.NORMAL=c),f}):void 0}})}}),Cfe=(n,e,t)=>n.map(r=>{const i=r.type===li.Group?r.children[0]:r;return{inverseBindMatrices:e.map(s=>s.type===Kt.BIND_MATRIX?s.meshName:null).indexOf(i.name),joints:i.skeleton.bones.map(s=>t.indexOf(s.name)).filter(s=>s!==-1),skeleton:t.indexOf(i.skeleton.bones[0].name)}}),Sfe=(n,e)=>n.map(t=>{let r,i=null;if(t=t.userData.vrmMaterial?t.userData.vrmMaterial:t,t.type==="ShaderMaterial")i={},i.shadeMultiplyTexture={index:e.map(p=>p.name).indexOf(t.uniforms.shadeMultiplyTexture.name)},r=t.color?[1,1,1,1]:void 0;else{const h=t;r=h.color?[h.color.r,h.color.g,h.color.b,1]:void 0}let s=-1;t.map?s=e.map(h=>h.name).indexOf(t.name):t.uniforms&&t.uniforms.map&&(s=e.map(h=>h.name).indexOf(t.uniforms.map.name));let o=-1;t.roughnessMap&&(o=e.map(h=>h.name).indexOf(t.name+"_orm"));let a=-1;t.normalMap&&(a=e.map(h=>h.name).indexOf(t.name+"_normal"));const l=s>=0?{extensions:{KHR_texture_transform:{offset:[0,0],scale:[1,1]}},index:s,texCoord:0}:void 0,A={baseColorFactor:r,baseColorTexture:l},c=o>=0?{index:o,texCoord:0}:void 0,u=a>=0?{index:a,texCoord:0}:void 0;if(c)A.metallicRoughnessTexture=c;else{const h=(()=>{switch(t.type){case Kf.MeshStandardMaterial:return t.metalness;case Kf.MeshBasicMaterial:return 0;default:return 0}})(),p=(()=>{switch(t.type){case Kf.MeshStandardMaterial:return t.roughness;case Kf.MeshBasicMaterial:return .9;default:return .9}})();A.metallicFactor=h,A.roughnessFactor=p}const f={alphaCutoff:t.alphaTest>0?t.alphaTest:void 0,alphaMode:t.transparent?"BLEND":t.alphaTest>0?"MASK":"OPAQUE",doubleSided:t.side===2,extensions:t.type==="ShaderMaterial"?{KHR_materials_unlit:{}}:void 0,name:t.name,pbrMetallicRoughness:A};return u&&(f.normalTexture=u),f}),Mfe=(n,e,t)=>(e?n.concat(e):n).filter(r=>r&&r.imageBitmap).map(r=>({bufferView:-1,mimeType:t,name:r.name})),Tfe=n=>n.map(()=>({magFilter:Dn.LINEAR,minFilter:Dn.LINEAR,wrapS:Dn.REPEAT,wrapT:Dn.REPEAT})),Ife=(n,e)=>e?n.map((t,r)=>({sampler:0,extensions:{KHR_texture_basisu:{source:r}}})):n.map((t,r)=>({sampler:0,source:r})),Rfe=(n,e)=>{const t=e.map(r=>r.name);return[{nodes:n.children.filter(r=>r.type===li.Object3D||r.type===li.SkinnedMesh||r.type===li.Group||r.type===li.Bone).map(r=>t.indexOf(r.name))}]};function Ffe(n,e,t){var a,l;const r=[],i=[];for(const A in n)((l=(a=n[A])==null?void 0:a.vrm)==null?void 0:l.meta)!=null&&(n[A].vrm.meta.authors!=null?i.push(n[A].vrm.meta):r.push(n[A].vrm.meta));r.length+i.length==1&&(r.length==1?r[0].title!=null&&(t=r[0].title):i[0].name!=null&&(t=i[0].name)),e!=null&&(e.authors!=null?i.push(e):r.push(e));const s=Lfe(r),o=Ufe(s,i);return o.licenseUrl="https://vrm.dev/licenses/1.0/",o.name=t,o}function Ufe(n,e){let{authors:t=[],otherLicenseUrl:r=[],contactInformation:i=[],references:s=[],allowExcessivelyViolentUsage:o=void 0,allowExcessivelySexualUsage:a=void 0,commercialUsage:l=void 0,copyrightInformation:A="",avatarPermission:c=void 0,otherPermissionUrl:u=[]}=n,f,h,p,d="unnecessary",g,m=[];e.forEach(b=>{t=t.concat(ct(b.authors)),r=r.concat(ct(b.otherLicenseUrl)),i=i.concat(ct(b.contactInformation)),s=s.concat(ct(b.references)),u=u.concat(ct(b.otherPermissionUrl)),b.allowExcessivelyViolentUsage===!1&&(o=!1),b.allowExcessivelySexualUsage===!1&&(a=!1),l=qa(Ofe,l,b.commercialUsage),A=qa(M5,A,b.copyrightInformation),c=qa(Nfe,c,b.avatarPermission),b.allowAntisocialOrHateUsage===!1&&(f=f=!1),b.allowPoliticalOrReligiousUsage===!1&&(h=h=!1),b.allowRedistribution===!1&&(p=p=!1),b.creditNotation==="required"&&(d="required"),m=m.concat(ct(b.thirdPartyLicenses)),g=qa(Dfe,g,b.modification)});const y=[...new Set(t)].filter(b=>b!=""&&b!=null&&b!="undefined"),w=[...new Set(r)].filter(b=>b!=""&&b!=null&&b!="undefined"),x=[...new Set(i)].filter(b=>b!=""&&b!=null&&b!="undefined"),_=[...new Set(s)].filter(b=>b!=""&&b!=null&&b!="undefined"),C=[...new Set(u)].filter(b=>b!=""&&b!=null&&b!="undefined"),S=[...new Set(m)].filter(b=>b!=""&&b!=null&&b!="undefined");return{authors:y,otherLicenseUrl:w.length==0?"":w.join(", "),contactInformation:x.length==0?"":x.join(", "),references:_,otherPermissionUrl:C.length==0?"":C.join(", "),thirdPartyLicenses:S.length==0?"":S.join(", "),allowExcessivelyViolentUsage:o,allowExcessivelySexualUsage:a,commercialUsage:l,copyrightInformation:A,avatarPermission:c,allowAntisocialOrHateUsage:f,allowPoliticalOrReligiousUsage:h,allowRedistribution:p,creditNotation:d,modification:g}}function Lfe(n){let e=[],t=[],r=[],i=[],s=[],o,a,l,A,c;n.forEach(g=>{e=e.concat(ct(g.author)),t=t.concat(ct(g.contactInformation)),r=r.concat(ct(g.reference)),i=i.concat(ct(g.otherPermissionUrl)),s=s.concat(ct(g.otherLicenseUrl)),o=qa(kfe,o,g.allowedUsername),a=qa(cB,a,g.violentUssageName),l=qa(cB,l,g.sexualUssageName),A=qa(cB,A,g.commercialUssageName),c=qa(M5,c,g.licenseName)});const u=[...new Set(e)].filter(g=>g!=""&&g!=null&&g!="undefined"),f=[...new Set(t)].filter(g=>g!=""&&g!=null&&g!="undefined"),h=[...new Set(r)].filter(g=>g!=""&&g!=null&&g!="undefined"),p=[...new Set(i)].filter(g=>g!=""&&g!=null&&g!="undefined"),d=[...new Set(s)].filter(g=>g!=""&&g!=null&&g!="undefined");return{authors:u,otherLicenseUrl:d,contactInformation:f,references:h,allowExcessivelyViolentUsage:a==="Allow",allowExcessivelySexualUsage:l==="Allow",commercialUsage:A==="Allow"?"personalProfit":"personalNonProfit",copyrightInformation:c,avatarPermission:Pfe(o),otherPermissionUrl:p}}function Pfe(n){if(n=="OnlyAuthor")return"onlyAuthor";if(n=="ExplicitlyLicensedPerson")return"onlySeparatelyLicensedPerson";if(n=="Everyone")return"everyone"}const Dfe={prohibited:0,allowModification:1,allowModificationRedistribution:2},Ofe={personalNonProfit:0,personalProfit:1,corporation:2},Nfe={onlyAuthor:0,onlySeparatelyLicensedPerson:1,everyone:2},kfe={OnlyAuthor:0,ExplicitlyLicensedPerson:1,Everyone:2},cB={Disallow:0,Allow:1},M5={Redistribution_Prohibited:0,Other:1,CC_BY_NC_ND:2,CC_BY_ND:3,CC_BY_NC_SA:4,CC_BY_SA:5,CC_BY_NC:6,CC_BY:7,CC0:8};function qa(n,e,t){return e===void 0?t:t==null||!(t in n)||n[e]{r.userData.origIndexBuffer&&t.push(r.userData.origIndexBuffer)}),e.traverse(r=>{r.userData.origIndexBuffer&&(r.userData.origIndexBuffer=t.shift())}),e}function Qfe(n){const e=T5(n);let t;const r=[];e.traverse(s=>{if(!t&&s.isSkinnedMesh&&(t=m5(s)),s.isSkinnedMesh){if(s.geometry=s.geometry.clone(),s.skeleton=t,r.push(s),Array.isArray(s.material)){const o=s.material;s.material=new kh,s.material.map=o[0].map}s.userData.origIndexBuffer&&s.geometry.setIndex(s.userData.origIndexBuffer)}});const i=new Ur;return r.forEach(s=>{i.add(s)}),i.add(t.bones[0]),i}async function Hfe(n,e,t){const r=await bT(n,t),i=await I5(r,e,t);return new Blob([i],{type:"model/gltf-binary"})}function zfe(n,e,t,r){return new Promise(async(i,s)=>{const o=`${t&&t!==""?t:"AvatarCreatorModel"}`;Gfe(n,e,r).then(a=>{F5(a,`${o}.vrm`),i()})})}async function Gfe(n,e,t){const r=await bT(n,t);return I5(r,e,t)}function bT(n,e){const t=T5(n),{createTextureAtlas:r=!0}=e;return r?Tue(t,e):(console.log("no atlas"),Cue(t,e))}async function Vfe(n,e="",t){const r=`${e&&e!==""?e:"AvatarCreatorModel"}`,{optimized:i=!0}=t,s=i?await bT(n,t):Qfe(n);jfe(s).then(o=>{if(o instanceof ArrayBuffer)F5(o,`${r}.glb`);else{const a=JSON.stringify(o,null,2);Xfe(a,`${r}.gltf`)}})}function jfe(n){return new Promise(e=>new aT().parse(n,r=>{e(r)},r=>{console.error("Error parsing",r)},{trs:!1,onlyVisible:!1,truncateDrawRange:!0,binary:!0,forcePowerOfTwoTextures:!1,maxTextureSize:1024}))}function Wfe(n){var r,i;const e=[];for(const s in n)if(((i=(r=n[s])==null?void 0:r.vrm)==null?void 0:i.springBoneManager)!=null){const o=n[s].vrm.springBoneManager.joints;for(const a of o)e.some(A=>A.name===a.bone.name)||e.push({name:a.bone.name,settings:a.settings,bone:a.bone,colliderGroups:a.colliderGroups,center:a.center})}const t=[];return e.forEach(s=>{for(const o in Km)if(s.bone.parent.name==Km[o]){t.push(s);break}}),t}function Kfe(n){const e={};return n.skeleton.bones.map(t=>{for(const r in Km)if(Km[r]===t.name){e[t.name]={node:t};break}}),e}function $fe(n,e){const t=zh(n,"SkinnedMesh");return{humanBones:Kfe(t[0]),materials:n.userData.atlasMaterial,meta:Yfe(e)}}function Yfe(n){return n=n||{},{...{authors:["CharacterStudio"],metaVersion:"1",version:"v1",name:"CharacterCreator",licenseUrl:"https://vrm.dev/licenses/1.0/",commercialUssageName:"personalNonProfit",contactInformation:"https://m3org.com/",allowExcessivelyViolentUsage:!1,allowExcessivelySexualUsage:!1,allowPoliticalOrReligiousUsage:!1,allowAntisocialOrHateUsage:!1,creditNotation:"required",allowRedistribution:!1,modification:"prohibited"},...n}}function I5(n,e,t){const{screenshot:r=null,isVrm0:i=!1,vrmMeta:s=null,scale:o=1,vrmName:a="CharacterCreator"}=t,l=Ffe(e,s,a);return new Promise(async A=>{const c=i?new _fe:new wce,u={...Jfe(e),...$fe(n,l)};let f;n.traverse(d=>{d.isSkinnedMesh&&(f=d)}),(()=>{for(let d=0;d{d.updateMatrix(),d.updateMatrixWorld()}),f.skeleton.calculateInverses(),f.skeleton.computeBoneTexture(),f.skeleton.update()})(),f.skeleton.bones.filter(d=>d.name==="head")[0];const p=Wfe(e);c.parse(u,n,r,p,t.ktxCompression,o,d=>{A(d)})})}function R5(n,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),t.href=URL.createObjectURL(n),t.download=e,t.click()}function Xfe(n,e){R5(new Blob([n],{type:"text/plain"}),e)}function F5(n,e){R5(Zfe(n),e)}function Zfe(n){return new Blob([n],{type:"application/octet-stream"})}function Jfe(n){for(const e in n)if(n[e].vrm)return n[e].vrm}const qfe=n=>{var e,t;(e=n.parser.json.extensions)!=null&&e.VRM?ehe(n):(t=n.parser.json.extensions)!=null&&t.VRMC_vrm?the(n):console.warn("No valid vrm file was provided")},ehe=n=>{var a,l,A;const e=n.parser.json,t=n.scene,r=e.nodes,i=(A=(l=(a=e.extensions)==null?void 0:a.VRM)==null?void 0:l.secondaryAnimation)==null?void 0:A.colliderGroups,s=[],o=r.map(c=>U5(c.name,s));i!=null&&i.forEach(c=>{const u=o[c.node],f=_5(t,u);if(f!=null){const h=c.colliders;f.userData.VRMcolliders=h.map(p=>({sphere:{radius:p.radius,offset:[p.offset.x,p.offset.y,p.offset.z]}}))}f.userData.VRMcollidersID=w5()})},the=n=>{var l,A,c,u;const e=n.parser.json,t=n.scene,r=e.nodes,i=(A=(l=e.extensions)==null?void 0:l.VRMC_springBone)==null?void 0:A.colliderGroups,s=(u=(c=e.extensions)==null?void 0:c.VRMC_springBone)==null?void 0:u.colliders,o=[],a=r.map(f=>U5(f.name,o));i!=null&&i.forEach(f=>{const h=ct(f.colliders);let p=-1,d=null;h.forEach(g=>{if(p!=s[g].node){p=s[g].node;const m=a[p];d=_5(t,m),d.userData.VRMcolliders=[]}if(d!=null){const m=s[g].shape;for(const y in m){const w=m[y];w!=null&&w.offset&&(w.offset[0]=-w.offset[0])}d.userData.VRMcollidersID=w5(),d.userData.VRMcolliders.push(m)}else console.error("no node with name "+a[p]+" was found")})})},U5=(n,e)=>{const t=_t.sanitizeNodeName(n||"");return t in e?t+"_"+ ++e[t]:(e[t]=0,t)},kw=[0,400,560,2400,4800],Qw=[0,500,700,3e3,6e3],XC=[],Va=[],BT=1024,L5=44100;for(let n=0;n{requestAnimationFrame(t),this.update(r,i)};t()}start(e){this.audioContext=new AudioContext,this.mediaStreamSource=this.audioContext.createMediaStreamSource(e),this.meter=Hw.createAudioMeter(this.audioContext),this.mediaStreamSource.connect(this.meter)}startFromAudioFile(e){this.audioContext||(this.audioContext=new AudioContext),this.userSpeechAnalyzer||(this.userSpeechAnalyzer=this.audioContext.createAnalyser()),this.userSpeechAnalyzer.smoothingTimeConstant=.5,this.userSpeechAnalyzer.fftSize=BT,this.mediaStreamSource&&this.mediaStreamSource.stop(),this.audioContext.decodeAudioData(e).then(t=>{this.mediaStreamSource=this.audioContext.createBufferSource(),this.mediaStreamSource.buffer=t,this.meter=Hw.createAudioMeter(this.audioContext),this.mediaStreamSource.connect(this.meter),this.mediaStreamSource.connect(this.audioContext.destination),this.mediaStreamSource.start(),this.mediaStreamSource.connect(this.userSpeechAnalyzer)})}destroy(){var e,t,r;return(e=this.meter)==null||e.shutdown(),this.meter=null,(t=this.mediaStreamSource)==null||t.disconnect(),((r=this.audioContext)==null?void 0:r.close().catch(()=>{}))||Promise.resolve()}update(e){if(this.meter){const{volume:t}=this.meter;if(t<.01)this.vrm.expressionManager.setValue(oi.Oh,0),this.vrm.expressionManager.setValue(oi.Ah,0),this.vrm.expressionManager.setValue(oi.Ee,0);else{const{ah:r,oh:i,ee:s}=this.update2();this.vrm.expressionManager.setValue(oi.Oh,i),this.vrm.expressionManager.setValue(oi.Ah,r),this.vrm.expressionManager.setValue(oi.Ee,s),this.vrm.expressionManager.update(e)}}}update2(){function e(A){const u=new Float32Array(A.length);for(let f=0;f0&&(i[A]+=r[c]);i[A]/=Va[A+1]-Va[A]}for(let A=0;A0&&(s[A]+=r[c]);i[A]/=Va[A+1]-Va[A],s[A]=s[A]/(XC[A+1]-XC[A])}const o=Math.max(s[1],i[1])>.2?1-2*Math.max(i[2],s[2]):(1-2*Math.max(i[2],s[2]))*5*Math.max(i[1],s[1]),a=3*Math.max(i[3],s[3]),l=.8*(Math.max(i[1],s[1])-Math.max(i[3],s[3]));return{oh:o,ee:l,ah:a}}static createAudioMeter(e){const t=e.createScriptProcessor(512);return t.onaudioprocess=r=>{const i=r.inputBuffer.getChannelData(0),s=i.length;let o=0,a;for(let A=0;A=t.clipLevel&&(t.clipping=!0,t.lastClip=window.performance.now()),o+=a*a;const l=Math.sqrt(o/s);t.volume=Math.max(l,t.volume*t.averaging)},t.clipping=!1,t.lastClip=0,t.volume=0,t.clipLevel=.98,t.averaging=.95,t.clipLag=750,t.connect(e.destination),t.checkClipping=()=>t.clipping?(t.lastClip+t.clipLag{t.disconnect(),t.onaudioprocess=null},t}}const uB=new Z;class nhe{constructor(e,t,r){this.bonesInfo=[],this.curMousePos=new $e,this.hotzoneSection=s(),this.enabled=!1,this.userActivated=!1,this.lookInterest=1,this.hasInterest=!0,this.interestSpeed=.3,this.onCanvas=!0,this.camera=r,this.maxLookPercent={neck:{maxy:15,miny:10,maxx:30,minx:10},spine:{maxy:0,miny:0,maxx:30,minx:10},left:{maxy:15,miny:20,maxx:35,minx:35},right:{maxy:15,miny:20,maxx:35,minx:35}},window.addEventListener("mousemove",o=>{this.curMousePos={x:o.clientX,y:o.clientY}});const i=document.getElementById(t);i&&(i.addEventListener("mouseleave",()=>{this.onCanvas=!1}),i.addEventListener("mouseenter",()=>{this.onCanvas=!0})),window.addEventListener("resize",()=>{this.hotzoneSection=s()});function s(){const o=window.innerWidth*e/100,a=(window.innerWidth-o)/2;return{xStart:a,xEnd:window.innerWidth-a,yStart:50,yEnd:window.innerHeight-80}}}setActive(e){console.log("is activating"),this.userActivated=e}setCamera(e){this.camera=e}addVRM(e){const t=e.data.isVRM0||!1,r=e.humanoid.humanBones;t||(r.neck.node.userData.inverseLookAt=!0,r.spine.node.userData.inverseLookAt=!0,r.leftEye&&(r.leftEye.node.userData.inverseLookAt=!0),r.rightEye&&(r.rightEye.node.userData.inverseLookAt=!0));const i={vrm:e,neckBone:r.neck.node,spineBone:r.spine.node,leftEyeBone:r.leftEye?r.leftEye.node:null,rightEyeBone:r.rightEye?r.rightEye.node:null};this.bonesInfo.push(i)}removeVRM(e){const t=this.bonesInfo.find(r=>r.vrm===e);if(t){const r=this.bonesInfo.indexOf(t);this.bonesInfo.splice(r,1)}}_getMouseDegrees(e,t,r){let i=0,s=0,o,a,l,A,c={x:window.innerWidth,y:window.innerHeight};return e<=c.x/2&&(o=c.x/2-e,a=o/(c.x/2)*100,i=r.maxx*a/100*-1),e>=c.x/2&&(o=e-c.x/2,a=o/(c.x/2)*100,i=r.minx*a/100),t<=c.y/2&&(l=c.y/2-t,A=l/(c.y/2)*100,s=r.maxy*.5*A/100*-1),t>=c.y/2&&(l=t-c.y/2,A=l/(c.y/2)*100,s=r.miny*A/100),{x:i,y:s}}lerp(e,t,r){return(1-r)*e+r*t}_moveJoint(e,t){const r=e.userData.inverseLookAt===!0?1:-1;if(Object.keys(e).length!==0){const i=(this.camera.position.y-1.8)*window.innerHeight/2;let s=this._getMouseDegrees(this.curMousePos.x,this.curMousePos.y-i,t);const o=.8;e.rotation.y=this.lerp(Lt.degToRad(s.x),e.rotation.y,o),e.rotation.x=this.lerp(Lt.degToRad(s.y*r),e.rotation.x,o)}}update(){uB.set(0,0,1),uB.applyQuaternion(this.camera.quaternion);const e=uB.z>0;this.curMousePos.x>this.hotzoneSection.xStart&&this.curMousePos.xthis.hotzoneSection.yStart&&this.curMousePos.y{this._moveJoint(t.neckBone,this.maxLookPercent.neck),this._moveJoint(t.spineBone,this.maxLookPercent.spine),this._moveJoint(t.leftEyeBone,this.maxLookPercent.left),this._moveJoint(t.rightEyeBone,this.maxLookPercent.right)})}}class fB{constructor(e){const{assetsLocation:t,traitsDirectory:r,thumbnailsDirectory:i,traitIconsDirectorySvg:s,animationPath:o,exportScale:a,displayScale:l,initialTraits:A,requiredTraits:c,randomTraits:u,colliderTraits:f,lipSyncTraits:h,blinkerTraits:p,typeRestrictions:d,defaultCullingLayer:g,defaultCullingDistance:m,offset:y,vrmMeta:w,traits:x,textureCollections:_,colorCollections:C,canDownload:S=!0,downloadOptions:b={}}=e;this.assetsLocation=t,this.traitsDirectory=r,this.thumbnailsDirectory=i,this.traitIconsDirectorySvg=s,this.displayScale=l||a||1,this.animationPath=ct(o),this.requiredTraits=ct(c),this.randomTraits=ct(u),this.initialTraits=A||[...new Set(this.requiredTraits.concat(this.randomTraits))],this.colliderTraits=ct(f),this.lipSyncTraits=ct(h),this.blinkerTraits=ct(p),this.typeRestrictions=d,this.defaultCullingLayer=g,this.defaultCullingDistance=m,this.offset=y,this.canDownload=S,this.downloadOptions=b;const M=()=>{const H=[];for(const I in x)H.push(x[I].trait);return H};this.allTraits=M(),M(),(()=>{if(this.typeRestrictions)for(const H in this.typeRestrictions)ct(this.typeRestrictions[H]).forEach(v=>{this.typeRestrictions[v]==null&&(this.typeRestrictions[v]=[]),this.typeRestrictions[v].indexOf(H)==-1&&this.typeRestrictions[v].push(H)})})(),(()=>{b.vrmMeta=b.vrmMeta||w,b.scale=b.scale||a||1,b.mToonAtlasSize=b.mToonAtlasSize||2048,b.mToonAtlasSizeTransp=b.mToonAtlasSizeTransp||1024,b.stdAtlasSize=b.stdAtlasSize||2048,b.stdAtlasSizeTransp=b.stdAtlasSizeTransp||1024,b.exportStdAtlas=b.exportStdAtlas||!1,b.exportMtoonAtlas=b.exportMtoonAtlas||!0,b.screenshotFaceDistance=b.screenshotFaceDistance||1,b.screenshotFaceOffset=b.screenshotFaceOffset||[0,0,0],b.screenshotResolution=b.screenshotResolution||[512,512],b.screenshotBackground=b.screenshotBackground||[.1,.1,.1],b.screenshotFOV=b.screenshotFOV||75,!b.exportStdAtlas&&!b.exportMtoonAtlas&&(b.exportMtoonAtlas=!0)})(),this.textureTraits=[],this.textureTraitsMap=null,this.createTextureTraits(_),this.colorTraits=[],this.colorTraitsMap=null,this.createColorTraits(C),this.modelTraits=[],this.modelTraitsMap=null,this.createModelTraits(x)}appendManifestData(e,t){e.textureTraits.forEach(r=>{const i=this.getTextureGroup(r.trait);i!=null?i.appendCollection(r,t):(this.textureTraits.push(r),this.textureTraitsMap.set(r.trait,r))}),e.colorTraits.forEach(r=>{const i=this.getColorGroup(r.trait);i!=null?i.appendCollection(r,t):(this.colorTraits.push(r),this.colorTraitsMap.set(r.trait,r))}),e.modelTraits.forEach(r=>{const i=this.getModelGroup(r.trait);i!=null?i.appendCollection(r,t):(this.modelTraits.push(r),this.modelTraitsMap.set(r.trait,r))}),console.log(e)}getExportOptions(){return this.downloadOptions}getGroupModelTraits(){return this.modelTraits}getInitialTraits(){return this.getRandomTraits(this.initialTraits)}getAllTraits(){return this.getRandomTraits(this.allTraits)}isColliderRequired(e){return this.colliderTraits.indexOf(e)!=-1}isLipsyncTrait(e){return this.lipSyncTraits.indexOf(e)!=-1}async getNFTraitOptionsFromURL(e,t){const r=await this._fetchJson(e);return this.getNFTraitOptionsFromObject(r,t)}getNFTraitOptionsFromObject(e,t){const r=e.attributes;if(r){t=ct(t);const i=[];return r.forEach(s=>{if(t.indexOf(s.trait_type)==-1){const o=this.getTraitOption(s.trait_type,s.value);o&&i.push(o)}}),i}else return console.warn("No attiributes parameter was found in ",e),null}getRandomTraits(e){const t=[];return(e||this.randomTraits).forEach(i=>{const s=this.getRandomTrait(i);s&&t.push(s)}),this._filterTraitOptions(t)}getRandomTrait(e){var r,i;const t=this.getModelGroup(e);if(t){const s=t.getRandomTrait();if(s){const o=(r=s.targetTextureCollection)==null?void 0:r.getRandomTrait(),a=(i=s.targetColorCollection)==null?void 0:i.getRandomTrait();return new hB(s,o,a)}else return null}else return console.warn("No trait group with name "+e+" was found."),null}async _fetchJson(e){return await(await fetch(e)).json()}getTraitOption(e,t){var i,s;const r=this.getModelTrait(e,t);if(r){const o=(i=r.targetTextureCollection)==null?void 0:i.getRandomTrait(),a=(s=r.targetColorCollection)==null?void 0:s.getRandomTrait();return new hB(r,o,a)}return null}_filterTraitOptions(e){const t=[],r=[];for(let i=0;i0&&console.log("options were filtered to fullfill restrictions: ",r),t}getCustomTraitOption(e,t){const r=this.getCustomModelTrait(e,t);return r?new hB(r,null,null):null}getCustomModelTrait(e,t){var r;return(r=this.getModelGroup(e))==null?void 0:r.getCustomTrait(t)}getModelTrait(e,t){var r;return(r=this.getModelGroup(e))==null?void 0:r.getTrait(t)}getModelTraits(e){const t=this.getModelGroup(e);return t?t.getCollection():(console.warn("No model group with name "+e),null)}getModelGroup(e){return this.modelTraitsMap.get(e)}getTextureTrait(e,t){var r;return(r=this.getTextureGroup(e))==null?void 0:r.getTrait(t)}getTextureGroup(e){return this.textureTraitsMap.get(e)}getColorTrait(e,t){var r;return(r=this.getColorGroup(e))==null?void 0:r.getTrait(t)}getColorGroup(e){return this.colorTraitsMap.get(e)}getTraitsDirectory(){let e=(this.assetsLocation||"")+(this.traitsDirectory||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getThumbnailsDirectory(){let e=(this.assetsLocation||"")+(this.thumbnailsDirectory||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getTraitIconsDirectorySvg(){let e=(this.assetsLocation||"")+(this.traitIconsDirectorySvg||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getAssetsDirectory(){let e=this.assetsLocation||"";return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}createModelTraits(e,t=!1){t&&(this.modelTraits=[]),ct(e).forEach(r=>{this.modelTraits.push(new rhe(this,r))}),this.modelTraitsMap=new Map(this.modelTraits.map(r=>[r.trait,r])),this.modelTraits.forEach(r=>{r.restrictedTraits.forEach(i=>{const s=this.getModelGroup(i);console.log(s),s&&s.addTraitRestriction(r.trait)})})}createTextureTraits(e,t=!1){t&&(this.textureTraits=[]),ct(e).forEach(r=>{this.textureTraits.push(new ihe(this,r))}),this.textureTraitsMap=new Map(this.textureTraits.map(r=>[r.trait,r]))}createColorTraits(e,t=!1){t&&(this.colorTraits=[]),ct(e).forEach(r=>{this.colorTraits.push(new she(this,r))}),this.colorTraitsMap=new Map(this.colorTraits.map(r=>[r.trait,r]))}}class rhe{constructor(e,t){const{trait:r,name:i,iconSvg:s,cameraTarget:o={distance:3,height:1},cullingDistance:a,cullingLayer:l,collection:A,restrictedTraits:c=[],restrictedTypes:u=[]}=t;this.manifestData=e,this.isRequired=e.requiredTraits.indexOf(r)!==-1,this.trait=r,this.name=i,this.iconSvg=s,this.fullIconSvg=e.getTraitIconsDirectorySvg()+s,this.restrictedTraits=c,this.restrictedTypes=u,this.cameraTarget=o,this.cullingDistance=a,this.cullingLayer=l,this.collection=[],this.collectionMap=null,this.createCollection(A)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Model with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Model with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}addTraitRestriction(e){this.restrictedTraits.indexOf(e)==-1&&this.restrictedTraits.push(e)}createCollection(e,t=!1){t&&(this.collection=[]),ct(e).forEach(r=>{this.collection.push(new Z3(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getCustomTrait(e){return new Z3(this,{directory:e,fullDirectory:e,id:"_custom",name:"Custom"})}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}getCollection(){return this.collection}}class ihe{constructor(e,t){const{trait:r,collection:i}=t;this.manifestData=e,this.trait=r,this.collection=[],this.collectionMap=null,this.createCollection(i)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Texture with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Texture with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}createCollection(e,t=!1){t&&(this.collection=[]),ct(e).forEach(r=>{this.collection.push(new ohe(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}}class she{constructor(e,t){const{trait:r,collection:i}=t;this.manifestData=e,this.trait=r,this.collection=[],this.collectionMap=null,this.createCollection(i)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Color with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Color with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}createCollection(e,t=!1){t&&(this.collection=[]),ct(e).forEach(r=>{this.collection.push(new ahe(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}}class Z3{constructor(e,t){const{id:r,directory:i,name:s,thumbnail:o,cullingDistance:a,cullingLayer:l,type:A=[],textureCollection:c,colorCollection:u,fullDirectory:f,fullThumbnail:h}=t;if(this.manifestData=e.manifestData,this.traitGroup=e,this.id=r,this.directory=i,f)this.fullDirectory=f;else if(Array.isArray(i)){this.fullDirectory=[];for(let p=0;p0&&this.manifestData.restrictedTypes>0){haveCommonValue=(i,s)=>{if(i==null||s==null)return!1;for(let o=0;ohaveCommonValue(r[i],traitTypes))}return!1}}class ohe{constructor(e,t){const{id:r,directory:i,fullDirectory:s,name:o,thumbnail:a}=t;if(this.traitGroup=e,this.id=r,this.directory=i,s)this.fullDirectory=s;else if(Array.isArray(i)){this.fullDirectory=[];for(let l=0;l{o.isSkinnedMesh&&o.skeleton.bones.filter(l=>l.name==="head")[0].getWorldPosition(Qa)}),Qa.z+=.3,Qa.y+=s,this.screenshotManager.setCamera(Qa,i),this.screenshotManager.saveScreenshot(e,t,r),this.blinkManager.disableScreenshot()}cameraRaycastCulling(e,t,r=!0){if(this.renderCamera==null){console.warn("No camera was set in character manager. Please call setRenderCamera(camera) before calling this function");return}const i=()=>{this.characterModel.traverse(A=>{A.isMesh&&A.userData.origIndexBuffer&&(A.userData.clippedIndexGeometry=A.geometry.index.clone(),A.geometry.setIndex(A.userData.origIndexBuffer))})},s=()=>{this.characterModel.traverse(A=>{A.isMesh&&A.userData.origIndexBuffer&&A.geometry.setIndex(A.userData.clippedIndexGeometry)})},o=(A,c)=>{for(let u=0;u{var d,g;const u=A.object,f=A.face,h=[f.a,f.b,f.c],p=(g=(d=u.userData)==null?void 0:d.clippedIndexGeometry)==null?void 0:g.array;if(p!=null){const m=o(p,h),y=Array.from(p);if(m==-1&&!c){const w=[...y,...h];u.userData.clippedIndexGeometry=new At(new Uint32Array(w),1,!1)}m!=1&&c&&(y.splice(m,3),u.userData.clippedIndexGeometry=new At(new Uint32Array(y),1,!1))}};dB.x=e,dB.y=t,i(),J3.setFromCamera(dB,this.renderCamera);const l=J3.intersectObjects(this.characterModel.children);if(l.length>0){const A=l[0];a(A,r)}s()}removeCurrentCharacter(){const e=[];for(const t in this.avatar)e.push(new gy({traitGroupID:t,traitModel:null}));e.forEach(t=>{this._addLoadedData(t)}),this.avatar={}}removeCurrentManifest(){this.removeCurrentCharacter(),this.manifest=null,this.manifestData=null,this.animationManager&&this.animationManager.clearCurrentAnimations()}canDownload(){var e;return((e=this.manifestData)==null?void 0:e.canDownload)||!0}downloadVRM(e,t=null){return new Promise(async(r,i)=>{if(this.canDownload())try{t=t||{};const o={...this.manifestData.getExportOptions(),...t};o.isVrm0=!0,o.screenshot=this._getPortaitScreenshotTexture(!1,o),console.log(o),await zfe(this.characterModel,this.avatar,e,o),r()}catch(s){console.error("Error downloading VRM:",s.message),i(new Error("Failed to download VRM."))}else{const s="Download not supported.";console.error(s),i(new Error(s))}})}downloadGLB(e,t=null){if(console.log("XXX fix glb downloader"),this.canDownload()){t=t||{};const r={...this.manifestData.getExportOptions(),...t};Vfe(this.characterModel,e,r)}else console.error("Download not supported")}getAvatarSelection(){var t;var e={};for(const r in this.avatar)e[r]={name:this.avatar[r].name,id:(t=this.avatar[r].traitInfo)==null?void 0:t.id};return e}getBoneTriangleCount(){let e=0,t=new Set;for(const r in this.avatar)this.avatar[r].model.traverse(i=>{i.isMesh&&(e+=i.geometry.index.array.length),i.isSkinnedMesh&&i.skeleton.bones.forEach(s=>{t.add(s.name)})});return{triangles:e/3,bones:t.size}}getGroupTraits(){if(this.manifestData)return this.manifestData.getGroupModelTraits()}getCurrentCharacterModel(){return this.characterModel}isTraitGroupRequired(e){const t=this.manifestData.getModelGroup(e);return!!(t!=null&&t.isRequired)}getTraits(e){return this.manifestData?this.manifestData.getModelTraits(e):(console.warn("No manifest file has been loaded, please load it before trait models."),null)}getCurrentTraitID(e){var t,r;return(r=(t=this.avatar[e])==null?void 0:t.traitInfo)==null?void 0:r.id}getCurrentTraitData(e){var t;return(t=this.avatar[e])==null?void 0:t.traitInfo}getCurrentTraitVRM(e){var t;return(t=this.avatar[e])==null?void 0:t.vrm}setParentModel(e){e.add(this.rootModel),this.parentModel=e,this.screenshotManager&&this.screenshotManager.setScene(this.parentModel)}setRenderCamera(e){this.renderCamera=e}loadRandomTraits(){return new Promise(async(e,t)=>{if(this.manifestData){const r=this.manifestData.getRandomTraits();await this._loadTraits(r),e()}else{const r="No manifest was loaded, random traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadRandomTrait(e){return new Promise(async(t,r)=>{if(this.manifestData){const i=this.manifestData.getRandomTrait(e);await this._loadTraits(ct(i)),t()}else{const i="No manifest was loaded, random traits cannot be loaded.";console.error(i),r(new Error(i))}})}loadTraitsFromNFT(e,t=!0,r=null){return new Promise(async(i,s)=>{try{if(this.manifestData){const o=this.manifestData.getNFTraitOptionsFromURL(e,r);await this._loadTraits(o,t),i()}else{const o="No manifest was loaded, NFT traits cannot be loaded.";console.error(o),s(new Error(o))}}catch(o){s(o)}})}loadTraitsFromNFTObject(e,t=!0,r=null){return new Promise(async(i,s)=>{if(this.manifestData)try{const o=this.manifestData.getNFTraitOptionsFromObject(e,r);await this._loadTraits(o,t),i()}catch(o){console.error("Error loading traits from NFT object:",o.message),s(new Error("Failed to load traits from NFT object."))}else{const o="No manifest was loaded, NFT traits cannot be loaded.";console.error(o),s(new Error(o))}})}loadInitialTraits(){return new Promise(async(e,t)=>{if(this.manifestData)await this._loadTraits(this.manifestData.getInitialTraits()),e();else{const r="No manifest was loaded, initial traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadAllTraits(){return console.log("load all"),new Promise(async(e,t)=>{if(this.manifestData)await this._loadTraits(this.manifestData.getAllTraits()),e();else{const r="No manifest was loaded, initial traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadTrait(e,t,r=!1){return new Promise(async(i,s)=>{if(this.manifestData)try{const o=this.manifestData.getTraitOption(e,t);o&&(await this._loadTraits(ct(o),r),i())}catch(o){console.error("Error loading specific trait:",o.message),s(new Error("Failed to load specific trait."))}else{const o="No manifest was loaded, specific trait cannot be loaded.";console.error(o),s(new Error(o))}})}loadCustomTrait(e,t){return new Promise(async(r,i)=>{if(this.manifestData)try{const s=this.manifestData.getCustomTraitOption(e,t);s&&(await this._loadTraits(ct(s)),r())}catch(s){console.error("Error loading custom trait:",s.message),i(new Error("Failed to load custom trait."))}else{const s="No manifest was loaded, custom trait cannot be loaded.";console.error(s),i(new Error(s))}})}loadCustomTexture(e,t){return new Promise(async(r,i)=>{var o;const s=(o=this.avatar[e])==null?void 0:o.model;if(s)await Pue(s,t),r();else{const a="No Group Trait with name "+e+" was found.";console.warn(a),i(new Error(a))}})}setTraitColor(e,t){var i;const r=(i=this.avatar[e])==null?void 0:i.model;if(r)try{const s=new Qe(t);r.traverse(o=>{o.isMesh&&(o.material.type==="MeshStandardMaterial"?Array.isArray(o.material)?o.material.forEach(a=>{a.color=s}):o.material.color=s:(o.material[0].uniforms.litFactor.value=s,o.material[0].uniforms.shadeColorFactor.value=new Qe(s.r*.8,s.g*.8,s.b*.8)))})}catch(s){throw console.error("Error setting trait color:",s.message),new Error("Failed to set trait color.")}else{const s="No Group Trait with name "+e+" was found.";throw console.warn(s),new Error(s)}}removeTrait(e,t=!1){if(this.isTraitGroupRequired(e)&&!t){console.warn(`No trait with name: ${e} is not removable.`);return}if(this.manifestData.getModelGroup(e)){const i=new gy({traitGroupID:e,traitModel:null});this._addLoadedData(i),oB(this.avatar)}else console.warn(`No trait with name: ${e} was found.`)}updateCullHiddenMeshes(){oB(this.avatar)}loadOptimizerManifest(){this.manifest={colliderTraits:["CUSTOM"],traits:[{name:"Custom",trait:"CUSTOM",collection:[]}]},this.manifestData=new fB(this.manifest)}getCurrentOptimizerCharacterModel(){var e;return(e=this.avatar.CUSTOM)==null?void 0:e.vrm}loadOptimizerCharacter(e){return this.loadCustomTrait("CUSTOM",e)}setManifest(e){return this.removeCurrentCharacter(),new Promise(async(t,r)=>{try{if(this.manifest=e,this.manifest){if(this.manifestData=new fB(this.manifest),this.animationManager)try{await this._animationManagerSetup(this.manifest.animationPath,this.manifest.assetsLocation,this.manifestData.displayScale)}catch(i){console.error("Error loading animations: "+i)}t()}else{const i="Failed to fetch or parse the manifest.";console.error(i),r(new Error(i))}}catch(i){console.error("Error setting manifest:",i.message),r(new Error("Failed to set the manifest."))}})}appendManifest(e,t){return new Promise(async(r,i)=>{try{t?this.manifest={...this.manifest||{},manifest:e}:this.manifest={manifest:e,...this.manifest||{}};const s=new fB(e);this.manifestData.appendManifestData(s),r()}catch(s){console.error("Error setting manifest:",s.message),i(new Error("Failed to set the manifest."))}})}loadManifest(e){return new Promise(async(t,r)=>{try{const i=await this._fetchManifest(e);this.setManifest(i).then(()=>{t()})}catch(i){console.error("Error loading manifest:",i.message),r(new Error("Failed to load the manifest."))}})}loadAppendManifest(e,t){return new Promise(async(r,i)=>{try{const s=await this._fetchManifest(e);this.appendManifest(s,t).then(()=>{r()})}catch(s){console.error("Error loading manifest:",s.message),i(new Error("Failed to load the manifest."))}})}async soloTargetGroupTrait(e){const t=ct(e),r=[];for(const i in this.avatar)t.includes(i)&&r.push(this.manifestData.getTraitOption(i,this.avatar[i].traitInfo.id));await this._loadTraits(r,!0)}storeCurrentAvatar(){this.storedAvatar={...this.avatar}}async loadStoredAvatar(){const e=[];for(const t in this.storedAvatar)e.push(this.manifestData.getTraitOption(t,this.storedAvatar[t].traitInfo.id));console.log(e),this._loadTraits(e,!0)}async _loadTraits(e,t=!1){console.log("laoded traits:",e),await this.traitLoadManager.loadTraitOptions(ct(e)).then(r=>{t&&this.getGroupTraits().forEach(s=>{r.some(a=>{var l;return((l=a.traitModel)==null?void 0:l.traitGroup.trait)===s.trait})||this.avatar[s.trait]!=null&&r.push(new gy({traitGroupID:s.trait,traitModel:null}))}),r.forEach(i=>{this._addLoadedData(i)}),oB(this.avatar)})}async _animationManagerSetup(e,t,r){const i=ct(e);this.animationManager&&(this.animationManager.setScale(r),e.length>0&&(this.animationManager.storeAnimationPaths(i,t||""),await this.animationManager.loadAnimation(i,!1,0,i[0].endsWith(".fbx"),t||"")))}async _fetchManifest(e){return await(await fetch(e)).json()}_getPortaitScreenshotTexture(e,t){this.blinkManager.enableScreenshot(),this.characterModel.traverse(u=>{u.isSkinnedMesh&&u.skeleton.bones.filter(h=>h.name==="head")[0].getWorldPosition(Qa)});const{screenshotResolution:r,screenshotFaceDistance:i,screenshotFaceOffset:s,screenshotBackground:o,screenshotFOV:a}=t,l=r[0],A=r[1];Qa.x+=s[0],Qa.y+=s[1],Qa.z+=s[2],this.screenshotManager.setBackground(o),this.screenshotManager.setCamera(Qa,i,a);const c=e?this.screenshotManager.getScreenshotBlob(l,A):this.screenshotManager.getScreenshotTexture(l,A);return this.blinkManager.disableScreenshot(),c}_setupWireframeMaterial(e){e.origMat=e.material;const t=()=>{const o=.1+Math.random()*.9,a=.1+Math.random()*(1-.1),l=.1+Math.random()*(1-.1);return new Qe(o,a,l)},r=new Ei({color:t(),wireframe:!0,wireframeLinewidth:.2}),i=e.material;e.setDebugMode=s=>{s?e.material.length?(e.material[0]=r,e.material[1]=r):e.material=r:e.material=i}}_VRMBaseSetup(e,t,r,i,s){var a,l;let o=e.userData.vrm;if(e.userData.vrm==null)return console.error("No valid VRM was provided for "+r+" trait, skipping file."),null;if(k3(o,{isVRM0:((a=o.meta)==null?void 0:a.metaVersion)==="0"}),this.manifestData.isColliderRequired(r)&&qfe(e),Hue(o),this.manifestData.isLipsyncTrait(r)&&(this.lipSync=new Hw(o)),this._modelBaseSetup(o,t,r,i,s),((l=o.meta)==null?void 0:l.metaVersion)==="0"){if(o.humanoid.humanBones.hips.node.parent==o.scene){const A=new It;A.name="newRootNode",Lue(o.scene,A),A.add(o.humanoid.humanBones.hips.node)}o.humanoid.humanBones.hips.node.parent.rotateY(3.14159),o.scene.traverse(A=>{var c;if(A.isSkinnedMesh){const u={},f=ct((c=A.geometry.userData)==null?void 0:c.targetNames);for(let h=0;h{const f=e.scene.getObjectByName(u);f!=null&&f.isMesh&&o.push(f)}),e.scene.traverse(u=>{!t.meshTargets&&u.isMesh&&o.push(u),u.frustumCulled=!1,u.isMesh&&(this._setupWireframeMaterial(u),a.indexOf(u.name)===-1&&l.push(u))});const A=this.manifest,c=this.manifestData.getModelGroup(r);k3(e,{cullingLayer:t.cullingLayer!=null?t.cullingLayer:c.cullingLayer!=null?c.cullingLayer:A.defaultCullingLayer!=null?A.defaultCullingLayer:-1,cullingDistance:t.cullingDistance!=null?t.cullingDistance:c.cullingDistance!=null?c.cullingDistance:A.defaultCullingDistance!=null?A.defaultCullingDistance:null,maxCullingDistance:t.maxCullingDistance!=null?t.maxCullingDistance:c.maxCullingDistance!=null?c.maxCullingDistance:A.maxCullingDistance!=null?A.maxCullingDistance:1/0,cullingMeshes:l}),o.map((u,f)=>{if(i){const h=i[f]||i[0];h!=null&&ct(u.material).map(p=>{che(p,h)})}if(s){const h=s[f]||s[0];h!=null&&(u.material[0].uniforms.litFactor.value=h,u.material[0].uniforms.shadeColorFactor.value=new Qe(h.r*.8,h.g*.8,h.b*.8))}})}_applyManagers(e){this.blinkManager.addVRM(e),this.lookAtManager&&this.lookAtManager.addVRM(e),this.animationManager&&this.animationManager.addVRM(e)}_displayModel(e){if(e){const t=e.scene;this.characterModel.attach(t)}}_positionModel(e){const t=this.manifestData.displayScale;e.scene.scale.set(t,t,t)}_disposeTrait(e){this.blinkManager.removeVRM(e),this.lookAtManager&&this.lookAtManager.removeVRM(e),this.animationManager&&this.animationManager.removeVRM(e),Que(e)}_addLoadedData(e){const{traitGroupID:t,traitModel:r,textureTrait:i,colorTrait:s,models:o,textures:a,colors:l}=e;if(r==null){this.avatar[t]&&this.avatar[t].vrm&&(this._disposeTrait(this.avatar[t].vrm),this.avatar[t]={});return}let A=null;o.map(c=>{c!=null&&(A=this._VRMBaseSetup(c,r,t,a,l))}),A!=null&&(this.avatar[t]&&this.avatar[t].vrm&&this._disposeTrait(this.avatar[t].vrm),this._positionModel(A),this._displayModel(A),this._applyManagers(A),console.log(this.characterModel),this.avatar[t]={traitInfo:r,textureInfo:i,colorInfo:s,name:r.name,model:A&&A.scene,vrm:A})}}class Ahe{constructor(){const e=new UH;e.onProgress=(i,s,o)=>{this.setLoadPercentage(Math.round(s/o*100))};const t=new QH(e);t.crossOrigin="anonymous",t.register(i=>new dce(i,{autoUpdateHumanBones:!0}));const r=new lu(e);this.loadPercentager=0,this.loadingManager=e,this.gltfLoader=t,this.textureLoader=r,this.isLoading=!1}setLoadPercentage(e){this.loadPercentager=e}loadTraitOptions(e){return new Promise(t=>{this.isLoading=!0;const r=[],i=e.map(async(s,o)=>{var c,u,f;if(s==null){r[o]=null;return}const a=await Promise.all(ct((c=s==null?void 0:s.traitModel)==null?void 0:c.fullDirectory).map(async h=>{try{return await this.gltfLoader.loadAsync(h)}catch(p){return console.error(`Error loading modelsss ${h}:`,p),null}})),l=await Promise.all(ct((u=s==null?void 0:s.traitTexture)==null?void 0:u.fullDirectory).map(h=>new Promise(p=>{this.textureLoader.load(h,d=>{d.flipY=!1,d.encoding=pt,p(d)},null,d=>{console.error("error loading texture: ",d),p(null)})}))),A=ct((f=s==null?void 0:s.traitColor)==null?void 0:f.value).map(h=>new Qe(h));r[o]=new gy({traitGroupID:s==null?void 0:s.traitModel.traitGroup.trait,traitModel:s==null?void 0:s.traitModel,textureTrait:s==null?void 0:s.traitTexture,colorTrait:s==null?void 0:s.traitColor,models:a,textures:l,colors:A})});Promise.allSettled(i).then(()=>{this.setLoadPercentage(100),t(r),this.isLoading=!1}).catch(s=>{this.setLoadPercentage(100),console.error("An error occurred:",s),t(r),this.isLoading=!1})})}}class gy{constructor(e){const{traitGroupID:t,traitModel:r,textureTrait:i,colorTrait:s,models:o,textures:a,colors:l}=e;this.traitGroupID=t,this.traitModel=r,this.textureTrait=i,this.colorTrait=s,this.models=o,this.textures=a,this.colors=l}}function che(n,e){if(n.type==="Shadermaterial"&&!n.isMToonMaterial){console.warn("XXX set material texture to shader material",n);return}n.map=e,n.needsUpdate=!0}function uhe(n){const e=new vw,t=new DH(16777215,.5);e.add(t);const r=new iT(16777215,.5);r.position.set(0,1,1),e.add(r);const i=new It;e.add(i);const s=new Fr(30,window.innerWidth/window.innerHeight,.1,1e3);s.position.set(0,1.3,2);const o=new lhe({parentModel:e,createAnimationManager:!0,renderCamera:s});o.addLookAtMouse(80,n,s,!0);const a=document.getElementById(n),l=new vg({canvas:a,antialias:!0,alpha:!0,preserveDrawingBuffer:!0}),A=new one(s,l.domElement);A.minDistance=1,A.maxDistance=4,A.maxPolarAngle=Math.PI/2,A.enablePan=!0,A.target=new Z(0,1,0),A.enableDamping=!0,A.dampingFactor=.1;const c=new Z(-.5,0,-.5),u=new Z(.5,1.5,.5),f=()=>{l.setSize(window.innerWidth,window.innerHeight),s.aspect=window.innerWidth/window.innerHeight,s.updateProjectionMatrix()};window.addEventListener("resize",f),l.setSize(window.innerWidth,window.innerHeight),l.setPixelRatio(window.devicePixelRatio),l.outputEncoding=pt;const h=()=>{requestAnimationFrame(h),A.target.clamp(c,u),A==null||A.update(),o.update(),l.render(e,s)};h();const p=g=>{const m=g.ctrlKey,y=a.getBoundingClientRect(),w=(g.clientX-y.left)/y.width*2-1,x=-((g.clientY-y.top)/y.height)*2+1;o.cameraRaycastCulling(w,x,m)};async function d(){}return d(),a.addEventListener("click",p),{scene:e,camera:s,controls:A,characterManager:o,sceneElements:i}}function xv(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var P5={exports:{}};/*! + `})}}const Nw=4096,rp=new Z;class tfe{constructor(e,t,r){const i=new vg({preserveDrawingBuffer:!0,antialias:!1,alpha:!0});this.pixelSize=r,this.domElement=i.domElement;const s=new $e(Nw,Nw);i.setClearColor(0,0),i.outputEncoding=cs,i.setSize(s.x,s.y),i.setPixelRatio(window.devicePixelRatio);let o=s.clone().divideScalar(r);o.x|=0,o.y|=0;const a=new Zue(i);a.addPass(new Jue(e,t)),this._renderPixelPass=new que(o,e,t),this._pixelPass=new efe(o),a.addPass(this._renderPixelPass),a.addPass(this._pixelPass),this.renderer=i,this.composer=a}setSize(e,t){let i=new $e(e,t).clone().divideScalar(this.pixelSize);i.x|=0,i.y|=0,this.renderer.setSize(e,t),this._renderPixelPass.setResolution(i),this._pixelPass.setResolution(i)}setPixelSize(e){this.pixelSize=e}render(){this.composer.render()}}class nfe{constructor(e,t){this.renderer=new vg({preserveDrawingBuffer:!0,antialias:!0,alpha:!0}),this.renderer.setClearAlpha(0),this.renderer.premultipliedAlpha=!1,this.scene=t,this.characterManager=e,this.renderer.outputEncoding=pt,this.renderer.setSize(Nw,Nw),this.camera=new Fr(30,1,.1,1e3),this.textureLoader=new lu,this.sceneBackground=new Qe(.1,.1,.1),this.sceneBackgroundAlpha=1,this.frameOffset={min:.2,max:.2},this.usesBackgroundImage=!1,this.backgroundMaterial=new Ei({color:16777215,transparent:!0,opacity:.5});const r=new ou(1e3,1e3),i=new xn(r,this.backgroundMaterial);i.renderOrder=-1,this.backgroundPlane=i,this.pixelRenderer=new tfe(t,this.camera,20),this.boneOffsets={head:null,neck:null,chest:null,hips:null,spine:null,leftUpperLeg:null,leftLowerLeg:null,leftFoot:null,rightUpperLeg:null,rightLowerLeg:null,rightFoot:null}}setScene(e){this.scene=e}setupCamera(e,t,r=30){this.camera.position.copy(e),this.camera.lookAt(t),this.camera.fov=r}_getCharacterMinMax(){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY;return this.characterManager.characterModel.traverse(r=>{r.geometry&&(r.geometry.computeBoundingBox(),r.geometry.boundingBox&&(r.geometry.boundingBox.applyMatrix4(r.matrixWorld),r.geometry.boundingBox.min.yt&&(t=r.geometry.boundingBox.max.y)))}),{minY:e,maxY:t}}frameCloseupShot(){this.frameShot("head","head")}frameMediumShot(){this.frameShot("chest","head")}frameCowboyShot(){this.frameShot("hips","head")}frameFullShot(){this.frameShot("leftFoot","head")}frameShot(e,t,r=null,i=!1,s=!0){const o=this._getBoneWorldPositionWithOffset(e,i),a=this._getBoneWorldPositionWithOffset(t,s);o.y-=this.frameOffset.max,a.y+=this.frameOffset.min,r=r||new Z(0,0,0),this.positionCameraBetweenPoints(o,a,r)}setBottomFrameOffset(e){this.frameOffset.min=e}setTopFrameOffset(e){this.frameOffset.max=e}async calculateBoneOffsets(e){for(const t in this.boneOffsets){const r=await this._getMinMaxOffsetByBone(this.characterManager.characterModel,t,e);this.boneOffsets[t]=r}}_getBoneWorldPositionWithOffset(e,t){const r=this._getFirstBoneWithName(e);if(!r||!this.boneOffsets[e])return new Z;const i=new Z;r.getWorldPosition(i);const s=t?this.boneOffsets[e].max:this.boneOffsets[e].min;return i.y+=s.y,i}_getBoneWorldPosition(e){const t=this._getFirstBoneWithName(e);return t!=null?new Z().setFromMatrixPosition(t.matrixWorld):(console.warn(`Bone with name '${e}' not found in one of the skinned meshes.`),new Z(0,0,0))}_getFirstBoneWithName(e){let t=null;return this.characterManager.characterModel.traverse(r=>{if(r instanceof Al){if(!r.geometry){console.error("Invalid skinned mesh found in children.");return}const i=r.skeleton.bones.findIndex(s=>s.name===e);if(i!==-1){t=r.skeleton.bones[i];return}}}),t}setCameraFrameWithName(e,t){switch(e.toLowerCase()){case"fullshot":this.frameShot("leftFoot","head",t);break;case"cowboyshot":this.frameShot("hips","head",t);break;case"mediumshot":this.frameShot("chest","head",t);break;case"mediumcloseup":case"mediumcloseupshot":this.frameShot("chest","head",t,!0);break;case"closeup":case"closeupshot":this.frameShot("head","head",t);break;default:console.warn("unkown cameraFrame: "+e+". Please use fullShot, cowboyShot, mediumShot, mediumCloseup or closeup"),this.frameShot("leftFoot","head",t);break}}async _getMinMaxOffsetByBone(e,t,r){return new Promise(async(i,s)=>{(!e||!e.traverse)&&(console.error("Invalid parent object provided."),s(null));const o=new Z(1/0,1/0,1/0),a=new Z(-1/0,-1/0,-1/0),l=[];e.traverse(async u=>{u instanceof Al&&(l.push(this._saveBonesPos(u.skeleton)),u.skeleton.pose())});let A=0;await(u=>new Promise(f=>setTimeout(f,u)))(10),e.traverse(u=>{if(u instanceof Al){if(!u.geometry){console.error("Invalid skinned mesh found in children.");return}const f=u.skeleton.bones.findIndex(g=>g.name===t);if(f===-1){console.error(`Bone with name '${t}' not found in one of the skinned meshes.`);return}const h=u.geometry.getAttribute("position"),p=u.geometry.getAttribute("skinWeight"),d=u.geometry.getAttribute("skinIndex");for(let g=0;g=r){const x=u.skeleton.bones[f],_=new Z().setFromMatrixPosition(x.matrixWorld),C=m.clone().sub(_);o.min(C),a.max(C)}}this._restoreSavedPose(l[A],u.skeleton),A++}}),i({min:o,max:a})})}_saveBonesPos(e){let t=[];return e.bones.forEach(r=>{t.push({position:r.position.clone(),rotation:r.rotation.clone(),scale:r.scale.clone()})}),t}_restoreSavedPose(e,t){e&&t.bones.forEach((r,i)=>{r.position.copy(e[i].position),r.rotation.copy(e[i].rotation),r.scale.copy(e[i].scale)})}positionCameraBetweenPoints(e,t,r,i=30){const s=new ps;s.expandByPoint(e),s.expandByPoint(t),this.camera.fov=i;const o=this.camera.fov*(Math.PI/180),l=s.getSize(new Z).length()/(2*Math.tan(o/2));s.getCenter(rp),this.camera.position.copy(rp),r.y*=.5,this.camera.lookAt(rp.clone().sub(r));const A=new Z;this.camera.getWorldDirection(A),this.camera.position.addScaledVector(A,-l),this.camera.updateProjectionMatrix()}setCamera(e,t,r=30){this.camera.position.copy(e),this.camera.fov=r,rp.set(0,0,-1),this.cameraDir=rp.applyQuaternion(this.camera.quaternion),this.cameraDir.normalize(),this.camera.position.x-=this.cameraDir.x*t,this.camera.position.z-=this.cameraDir.z*t}setBackground(e){if(Array.isArray(e)){const t=e[3]==null?1:e[3];this.setBackgroundColor(e[0],e[1],e[2],t)}else this.setBackgroundImage(e)}setBackgroundColor(e,t,r,i){const s=new Qe(e,t,r,i);this.sceneBackground=s,i==null&&(i=1),i>1&&(i=1),i<0&&(i=0),this.sceneBackgroundAlpha=i,this.backgroundMaterial.color=s,this.usesBackgroundImage=!1}setBackgroundImage(e){return new Promise(async(t,r)=>{try{const i=await this.texureLoader.load(e);i&&(i.wrapS=i.wrapT=As,this.sceneBackground=i,this.usesBackgroundImage=!0,this.sceneBackgroundAlpha=1,t())}catch(i){console.error("Error loading background image: ",i),r(i)}})}_setBackground(){if(this.usesBackgroundImage==!1&&this.sceneBackgroundAlpha!=1)if(this.sceneBackgroundAlpha==0)this.scene.background=null;else{this.scene.background=null,this.scene.add(this.backgroundPlane),this.backgroundPlane.position.copy(this.camera.position);var e=new Z(0,0,-1);e.applyQuaternion(this.camera.quaternion);var t=100;this.backgroundPlane.position.addScaledVector(e,t),this.backgroundPlane.lookAt(this.camera.position)}else this.scene.background=this.sceneBackground}_restoreBackground(){this.scene.background=null,this.usesBackgroundImage==!1&&this.sceneBackgroundAlpha!=1&&this.scene.remove(this.backgroundPlane)}getImageData(e,t,r=null){return this._createImage(e,t,r).split("base64,")[1]}_createImage(e,t,r=null){const i=e/t;typeof r=="number"&&this.pixelRenderer.setPixelSize(r),this.renderer.setSize(e,t),this.pixelRenderer.setSize(e,t);const s="image/png";this.camera.aspect=i,this.camera.updateProjectionMatrix();const o=typeof r=="number"?this.pixelRenderer:this.renderer;try{this._setBackground(),o.render(this.scene,this.camera);let a=o.domElement.toDataURL(s);return this._restoreBackground(),a}catch(a){return console.error(a),null}}savePixelScreenshot(e,t,r,i){this.pixelRenderer.setPixelSize(i),this.pixelRenderer.setSize(t,r);const s=this._createImage(t,r,!0),o="image/octet-stream",a="image/png";this.saveFile(s.replace(a,o),e+".png")}saveScreenshot(e,t,r){const i=this._createImage(t,r),s="image/octet-stream",o="image/png";this.saveFile(i.replace(o,s),e+".png")}getScreenshotImage(e,t){const r=this._createImage(e,t),i=new Image;return i.src=r,i}getScreenshotTexture(e,t){const r=this.getScreenshotImage(e,t),i=new Qn(r);return i.needsUpdate=!0,i}getScreenshotBlob(e,t){const r=this._createImage(e,t),i=t6.Buffer.from(r.replace(/^data:image\/\w+;base64,/,""),"base64");return new Blob([i],{type:"image/jpeg"})}saveFile(e,t){const r=document.createElement("a");typeof r.download=="string"?(document.body.appendChild(r),r.download=t,r.href=e,r.click(),document.body.removeChild(r)):window.open(e,"_blank").document.write(""+t+"")}}const rfe=2;class ife{constructor(e=.5,t=.5,r=1,i=5){this.vrmBlinkers=[],this.mode="ready",this.clock=new OH,this.closeTime=e,this.openTime=t,this.continuity=r,this.randomness=i,this._eyeOpen=1,this._blinkCounter=0,this.isTakingScreenShot=!1,this.update()}addVRM(e){this.vrmBlinkers.push(e)}removeVRM(e){const t=this.vrmBlinkers.indexOf(e);t!==-1&&this.vrmBlinkers.splice(t,1)}enableScreenshot(){this.isTakingScreenShot=!0,this._eyeOpen=rfe,this._updateBlinkers()}disableScreenshot(){this.isTakingScreenShot=!1}update(){setInterval(()=>{if(this.isTakingScreenShot)return;const e=this.clock.getDelta();switch(this.mode){case"closing":this._eyeOpen>0?this._eyeOpen-=e/this.closeTime:(this._eyeOpen=0,this.mode="open"),this._updateBlinkers();break;case"open":this._eyeOpen<1?this._eyeOpen+=e/this.openTime:(this._eyeOpen=1,this.mode="ready"),this._updateBlinkers();break;case"ready":this._blinkCounter+=e,this._blinkCounter>=this.continuity&&(Math.floor(Math.random()*this.randomness)===0&&(this.mode="closing"),this._blinkCounter=0);break}},1e3/30)}_updateBlinkers(){this.vrmBlinkers.forEach(e=>{e.expressionManager.setValue(oi.Blink,1-this._eyeOpen),e.expressionManager.update()})}}function E5(){return(E5=Object.assign||function(n){for(var e=1;e0?u+s.byteLength:0;f%8&&(f+=8-f%8);let h=[],p=new DataView(new ArrayBuffer(24*n.levels.length)),d=(f||u+s.byteLength)+t.byteLength;for(let y=0;y0?f:0),!0),m.setBigUint64(60,BigInt(t.byteLength),!0),new Uint8Array(sp([new Uint8Array(Tr).buffer,g,p.buffer,a,s,new ArrayBuffer(f>0?f-(u+s.byteLength):0),t,...h]))}var VC,jC,ufe={enableDebug:!1,isUASTC:!0,isKTX2File:!0,isInputSRGB:!0,generateMipmap:!0,needSupercompression:!0,isSetKTX2SRGBTransferFunc:!0},WC=new OffscreenCanvas(128,128),j3=WC.getContext("2d",{willReadFrequently:!0}),C5=typeof document>"u";function ffe(n){return createImageBitmap(n).then(function(e){return WC.width=e.width,WC.height=e.height,j3.drawImage(e,0,0),j3.getImageData(0,0,e.width,e.height)})}function hfe(n,e){return e===void 0&&(e={}),pfe().then(function(t){var r=new t.BasisEncoder;return dfe(e,r),r.setTexType(VC.cBASISTexType2D),ofe(n,ArrayBuffer)&&(n=new Blob([n])),ffe(n).then(function(i){r.setSliceSourceImage(0,new Uint8Array(i.data),i.width,i.height,jC.RAW);var s=new Uint8Array(10485760),o=r.encode(s);if(o===0)throw"encode failed";var a=new Uint8Array(s.buffer,0,o),l=lfe(s);if(e.kvData){for(var A in e.kvData)l.keyValue[A]=e.kvData[A];a=cfe(l,{keepWriter:!0})}return a})})}function dfe(n,e){n===void 0&&(n={}),(n=sfe({},ufe,n)).enableDebug!==void 0&&e.setDebug(n.enableDebug),n.isUASTC!==void 0&&e.setUASTC(n.isUASTC),n.isKTX2File!==void 0&&e.setCreateKTX2File(n.isKTX2File),n.isSetKTX2SRGBTransferFunc!==void 0&&e.setKTX2SRGBTransferFunc(n.isSetKTX2SRGBTransferFunc),n.generateMipmap!==void 0&&e.setMipGen(n.generateMipmap),n.isYFlip!==void 0&&e.setYFlip(n.isYFlip),n.qualityLevel!==void 0&&e.setQualityLevel(n.qualityLevel),n.compressionLevel!==void 0&&e.setCompressionLevel(n.compressionLevel),n.needSupercompression!==void 0&&e.setKTX2UASTCSupercompression(n.needSupercompression),n.isNormalMap!==void 0&&e.setNormalMap(n.isNormalMap)}var lB=null;function pfe(){return lB||(lB=new Promise(function(n,e){C5?(importScripts("https://mdn.alipayobjects.com/rms/afts/file/A*SrRkQarYYl4AAAAAAAAAAAAAARQnAQ/basis_encoder.js"),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qFWbTrA0hZYAAAAAAAAAAAAAARQnAQ/basis_encoder.wasm").then(function(t){return t.arrayBuffer()}).then(function(t){BASIS({wasmBinary:t}).then(function(r){r.initializeBasis(),n(r)}).catch(e)}).catch(e)):Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*SrRkQarYYl4AAAAAAAAAAAAAARQnAQ/basis_encoder.js").then(function(t){return t.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qFWbTrA0hZYAAAAAAAAAAAAAARQnAQ/basis_encoder.wasm").then(function(t){return t.arrayBuffer()})]).then(function(t){var r=t[0],i=t[1],s=document.createElement("script");s.onload=function(){BASIS({wasmBinary:i}).then(function(o){o.initializeBasis(),n(o)}).catch(e)},s.src=URL.createObjectURL(new Blob([r])),s.onerror=e,document.body.appendChild(s)}).catch(e)})),lB}C5&&self.addEventListener("message",function(n){hfe(n.data).then(function(e){self.postMessage(e)}).catch(function(e){self.postMessage({error:e})})});class mfe{constructor(e,t){if(this.gl=e,this.libktx=null,e!==void 0)if(t===void 0&&LIBKTX!==void 0&&(t=LIBKTX),t!==void 0)this.initializied=this.init(e,t);else{console.error("Failed to initalize KTXDecoder: ktx library undefined");return}else{console.error("Failed to initalize KTXDecoder: WebGL context undefined");return}}async init(e,t){this.libktx=await t({preinitializedWebGLContext:e}),this.libktx.GL.makeContextCurrent(this.libktx.GL.createContext(e.canvas,{majorVersion:2}))}stringToUastcFlags(e){return e==="FASTER"?this.libktx.UastcFlags.LEVEL_FASTER.value:e==="FASTEST"?this.libktx.UastcFlags.LEVEL_FASTEST.value:e==="SLOWER"?this.libktx.UastcFlags.LEVEL_SLOWER.value:e==="SLOWEST"?this.libktx.UastcFlags.LEVEL_VERYSLOW.value:this.libktx.UastcFlags.LEVEL_DEFAULT.value}stringToSupercmpScheme(e){return e==="Zstd"?this.libktx.SupercmpScheme.ZSTD:e==="Zlib"?this.libktx.SupercmpScheme.ZLIB:e==="BasisLZ"?this.libktx.SupercmpScheme.BASIS_LZ:this.libktx.SupercmpScheme.NONE}transcodeRGBA(e){if(!e.needsTranscoding)return;const t=this.libktx.TranscodeTarget.RGBA8888;e.transcodeBasis(t,0)!=this.libktx.ErrorCode.SUCCESS&&console.warn("Texture transcode failed. See console for details.")}transcode(e){if(e.gpuFormat="RGBA8888",e.needsTranscoding){let t,r=!1,i=!1,s=!1,o=!1,a=!1;r=!!this.gl.getExtension("WEBGL_compressed_texture_astc"),i=!!this.gl.getExtension("WEBGL_compressed_texture_etc1"),s=!!this.gl.getExtension("WEBGL_compressed_texture_s3tc"),o=!!this.gl.getExtension("EXT_texture_compression_bptc"),a=!!this.gl.getExtension("WEBGL_compressed_texture_pvrtc")||!!this.gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),r?(t=this.libktx.TranscodeTarget.ASTC_4x4_RGBA,e.gpuFormat="ASTC_4x4_RGBA"):o?(t=this.libktx.TranscodeTarget.BC7_RGBA,e.gpuFormat="BC7_RGBA"):s?(t=this.libktx.TranscodeTarget.BC1_OR_3,e.gpuFormat="BC1_OR_3"):a?(t=this.libktx.TranscodeTarget.PVRTC1_4_RGBA,e.gpuFormat="PVRTC1_4_RGBA"):i?(t=this.libktx.TranscodeTarget.ETC,e.gpuFormat="ETC"):(t=this.libktx.TranscodeTarget.RGBA8888,e.gpuFormat="RGBA8888"),e.transcodeBasis(t,0)!=this.libktx.ErrorCode.SUCCESS&&console.warn("Texture transcode failed. See console for details.")}}async loadKtxFromUri(e){await this.initializied;const t=await fetch(e),r=new Uint8Array(await t.arrayBuffer()),i=new this.libktx.ktxTexture(r);this.transcode(i);let s=i.glUpload();if(s.texture==null){console.error("Could not load KTX data");return}return s.texture.levels=Math.log2(i.baseWidth),s.texture.width=i.baseWidth,s.texture.height=i.baseHeight,s.texture.gpuSize=i.dataSize,s.texture.gpuFormat=i.gpuFormat,s.texture.isSRGB=i.isSRGB,s.texture}async loadKtxFromBuffer(e){await this.initializied;const t=new this.libktx.ktxTexture(e);this.transcode(t);const r=t.glUpload();if(r.texture==null){console.error("Could not load KTX data");return}return r.texture.levels=Math.log2(t.baseWidth),r.texture.width=t.baseWidth,r.texture.height=t.baseHeight,r.texture.gpuSize=t.dataSize,r.texture.gpuFormat=t.gpuFormat,r.texture.isSRGB=t.isSRGB,r.texture}async compress(e,t,r,i,s={}){const o=new this.libktx.ktxTexture(e,t,r,i,s.srgb);if(!s.hasOwnProperty("basisu_options")){const A=new this.libktx.ktxBasisParams;A.uastc=!1,A.noSSE=!0,A.verbose=!1,A.qualityLevel=100,A.compressionLevel=2,s.basisu_options=A}s.hasOwnProperty("compression_level")||(s.compression_level=18),s.hasOwnProperty("supercmp_scheme")||(s.supercmp_scheme=this.libktx.SupercmpScheme.NONE),console.log(s);const a=o.compressBasisU(s.basisu_options,s.supercmp_scheme,s.compression_level);return Uint8ClampedArray.from(a)}}class gfe{constructor(){this.ktxEncoder=null,this.libktx=null,this.init()}async init(){const t=document.createElement("canvas").getContext("webgl"),r=new mfe(t,window.LIBKTX);await r.init(t,window.LIBKTX),this.ktxEncoder=r,this.libktx=r.libktx}async compress(e,t,r,i,s={}){const o=await new this.libktx.ktxBasisParams,a=s;return o.uastc=a.uastc!==void 0?a.uastc:!1,o.noSSE=a.noSSE!==void 0?a.noSSE:!1,o.verbose=a.verbose!==void 0?a.verbose:!1,o.normalMap=a.normalMap!==void 0?a.normalMap:!1,o.compressionLevel=a.compressionLevel!==void 0?a.compressionLevel:1,o.qualityLevel=a.qualityLevel!==void 0?a.qualityLevel:60,o.maxEndpoints=a.ETC1SmaxEndpoints!==void 0?a.ETC1SmaxEndpoints:0,o.endpointRDOThreshold=a.ETC1SEndpointRdoThreshold!==void 0?a.ETC1SEndpointRdoThreshold:1.25,o.maxSelectors=a.ETC1SMaxSelectors!==void 0?a.ETC1SMaxSelectors:0,o.selectorRDOThreshold=a.ETC1SSelectorRdoThreshold!==void 0?a.ETC1SSelectorRdoThreshold:1.25,o.noEndpointRDO=a.ETC1SNoEndpointRdo!==void 0?a.ETC1SNoEndpointRdo:!1,o.noSelectorRDO=a.ETC1SNoSelectorRdo!==void 0?a.ETC1SNoSelectorRdo:!1,o.uastcFlags=this.ktxEncoder.stringToUastcFlags(a.uastcFlags),o.uastcRDO=o.uastcRDO!==void 0?o.uastcRDO:!1,o.uastcRDOQualityScalar=a.uastcRDOQualityScalar!==void 0?a.uastcRDOQualityScalar:1,o.uastcRDODictSize=a.uastcRDODictSize!==void 0?a.uastcRDOQualityScalar:4096,o.uastcRDOMaxSmoothBlockErrorScale=a.uastcRDOMaxSmoothBlockErrorScale!==void 0?a.uastcRDOMaxSmoothBlockErrorScale:10,o.uastcRDOMaxSmoothBlockStdDev=a.uastcRDOMaxSmoothBlockStdDev!==void 0?a.uastcRDOMaxSmoothBlockStdDev:18,o.uastcRDODontFavorSimplerModes=a.uastcRDODontFavorSimplerModes!==void 0?a.uastcRDODontFavorSimplerModes:!1,s.basisu_options=o,s.hasOwnProperty("supercmp_scheme")?s.supercmp_scheme=this.ktxEncoder.stringToSupercmpScheme(s.supercmp_scheme):s.supercmp_scheme=this.libktx.SupercmpScheme.NONE,await this.ktxEncoder.compress(e,t,r,i,s)}}var Dn;(function(n){n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n[n.BYTE=5120]="BYTE",n[n.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",n[n.SHORT=5122]="SHORT",n[n.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",n[n.UNSIGNED_INT=5125]="UNSIGNED_INT",n[n.FLOAT=5126]="FLOAT",n[n.LINEAR=9729]="LINEAR",n[n.REPEAT=10497]="REPEAT"})(Dn||(Dn={}));const KC="blend_",W3="vrmColliderSphere";function vfe(n){var e;return{title:n.name,version:"v0",author:((e=n.authors)==null?void 0:e.length)>0?n.authors.join(", "):"",reference:n.references!=null?n.references.join(", "):"",contactInformation:n.contactInformation!=null?n.contactInformation:"",otherPermissionUrl:n.otherPermissionUrl,allowedUserName:n.avatarPermission!=null?n.avatarPermission:"",violentUssageName:n.allowExcessivelyViolentUsage?"Allow":"Disallow",sexualUssageName:n.allowExcessivelySexualUsage?"Allow":"Disallow",commercialUssageName:n.commercialUsage=="personalProfit"||n.commercialUsage=="corporation"?"Allow":"Disallow",licenseName:n.copyrightInformation,otherLicenseUrl:n.otherLicenseUrl,metaVersion:"0"}}function yfe(n){const e=[];for(const t in n.humanBones)e.push({bone:t,node:n.humanBones[t].node});return{humanBones:e}}function wfe(n){switch(n){case"happy":return"joy";case"sad":return"sorrow";case"relaxed":return"fun";case"aa":return"a";case"ih":return"i";case"ou":return"u";case"ee":return"e";case"oh":return"o";default:return n}}function xfe(n){if(n.includes("Thumb")){if(n.includes("Metacarpal"))return n.replace("Metacarpal","Proximal");if(n.includes("Proximal"))return n.replace("Proximal","Intermediate")}return n}class _fe{async parse(e,t,r,i,s,o,a){var be;const l=vfe(e.meta),A=yfe(e.humanoid),c=e.materials,u=[],f={generator:"UniGLTF-2.0.0",version:"2.0"};if(t)if(A)if(l){if(!c)throw new Error("materials is undefined or null")}else throw new Error("meta is undefined or null");else throw new Error("humanoid is undefined or null");else throw new Error("avatar is undefined or null");const h=c.filter((N,j,se)=>se.findIndex(he=>he.name===N.name.replace(" (Outline)",""))===j).map(N=>N),p=h.map(N=>N.name),d=r?{name:"icon",imageBitmap:r.image}:null,g=h.filter(N=>N.map).map(N=>{if(!N.map)throw new Error(N.name+" map is null");return{name:N.name,imageBitmap:N.map.image}}),m=h.filter(N=>N.userData.shadeTexture).map(N=>{if(!N.userData.shadeTexture)throw new Error(N.userData.shadeTexture+" map is null");return{name:N.name+"_shade",imageBitmap:N.userData.shadeTexture.image}}),y=h.filter(N=>N.roughnessMap).map(N=>N.roughnessMap?{name:N.name+"_orm",imageBitmap:N.roughnessMap.image}:null),w=h.filter(N=>N.roughnessMap).map(N=>N.normalMap?{name:N.name+"_normal",imageBitmap:N.normalMap.image}:null),x=[...g,...m,...y,...w].filter(N=>N!==null),_=Mfe(x,d,s?"image/ktx2":"image/png"),C=Tfe(_),S=Ife(_,s),b=Sfe(h,x),M=t.children.filter(N=>N.children.length>0&&N.children[0].type===li.Bone)[0],D=S5(M).filter(N=>N.name!==W3),$=D.map(N=>N.name),H=D.map(N=>{const j=N.children.filter(se=>se.name!==W3).map(se=>$.indexOf(se.name));return{name:N.name,rotation:[N.quaternion.x,N.quaternion.y,N.quaternion.z,N.quaternion.w],scale:[N.scale.x,N.scale.y,N.scale.z],translation:[N.position.x,N.position.y,N.position.z],children:j.length>0?j:void 0}}),I=[],v=t.children.filter(N=>N.type===li.Group||N.type===li.SkinnedMesh),E=[];v.forEach((N,j)=>{const se=N.type===li.Group?N.children[0]:N,he=se.geometry.attributes,me=new Gl(he.position,Dn.FLOAT,Kt.POSITION,zo.VEC3,se.name,void 0);E.push(me);const G=E.length-1,R=he.normal.array,T=new Float32Array(R.length);for(let ie=0;ieie):[N]).forEach(ie=>{if(!ie.geometry.index)throw new Error(ie.name+" geometry.index is null");E.push(new Gl(ie.geometry.index,Dn.UNSIGNED_INT,Kt.INDEX,zo.SCALAR,se.name,ie.name))}),se.morphTargetDictionary||(se.morphTargetDictionary={},se.morphTargetInfluences=[],se.geometry.morphAttributes={},se.updateMorphTargets()),se.geometry.userData.targetNames=[];const ae=(ie,Te,Me,Le)=>{const ke=[],De=[];for(let fe=0;fe0){const fe=[...ke].sort((Fe,We)=>Fe-We),Ce=[];for(let Fe=0;Fe({mesh:0,index:he.index,weight:he.weight*100}));if(se.length>0){let he=!1;for(const me in oi)if(N===oi[me]&&N!=="surprised"){u.push({name:N,presetName:wfe(N),binds:se,isBinary:j.isBinary}),he=!0;break}he===!1&&u.push({name:N,presetName:"unknown",binds:se,isBinary:j.isBinary})}}v.forEach(N=>{const j=N.type===li.Group?N.children[0]:N,se=new Float32Array(j.skeleton.boneInverses.map(he=>he.elements).flat());E.push(new Gl(new At(se,16),Dn.FLOAT,Kt.BIND_MATRIX,zo.MAT4,j.name,j.name))}),I.push(...E.map(N=>({componentType:N.valueType,count:N.attribute.count,max:N.max,min:N.min,normalized:!1,type:N.accessorsType})));const U=Efe(v,E,p);v.forEach((N,j)=>{H.push({mesh:j,name:N.name,rotation:[N.quaternion.x,N.quaternion.y,N.quaternion.z,N.quaternion.w],scale:[N.scale.x,N.scale.y,N.scale.z],skin:j,translation:[N.position.x,N.position.y,N.position.z]})});const P=Cfe(v,E,$),L={humanBones:[]};A.humanBones.forEach(N=>{$.indexOf(N.node.name)!=-1&&L.humanBones.push({bone:xfe(N.bone),node:$.indexOf(N.node.name),useDefaultValues:!0})});const z={floatProperties:{_DstBlend:.5,_ShadeShift:.5,_ShadeToony:.5,_ShadingGradeRate:.5},keywordMap:{_NORMALMAP:!1,MTOON_OUTLINE_COLOR_FIXED:!0,MTOON_OUTLINE_WIDTH_WORLD:!0},name:"VRMCombinedMat",renderQueue:2e3,shader:"VRM/MToon",tagMap:{RenderType:"Opaque"},textureProperties:{_MainTex:0,_ShadeTexture:0},vectorProperties:{_Color:[1,1,1,1],_EmissionColor:[0,0,0,1],_EmissionMap:[0,0,1,1],_MainTex:[0,0,1,1],_OutlineColor:[0,0,0,1],_OutlineWidthTexture:[0,0,1,1],_ReceiveShadowTexture:[0,0,1,1],_RimColor:[0,0,0,1],_RimTexture:[0,0,1,1],_ShadeColor:[.9,.9,.9,1]}},K={name:"STDCombinedMat",shader:"VRM_USE_GLTFSHADER"},O=[];h.forEach(N=>{N.type=="ShaderMaterial"?O.push(Object.assign({},z)):O.push(Object.assign({},K))});const B=l;i.forEach(N=>{for(let j=0;jN.isSkinnedMesh))==null?void 0:be.skeleton)||null;for(let N=0;N{const me=he.sphere;se.colliders.push({radius:me.radius*o,offset:{x:me.offset[0]*o,y:me.offset[1]*o,z:me.offset[2]*o}})}),W.push(se)}}console.log("COLLIDER GROUPS",W);const F=N=>{for(let j=0;j{var G;const j=F(N.name);if(j===-1){console.warn("Spring bone "+N.name+" was removed during cleanup process. Skipping.");return}const se=[];N.colliderGroups.forEach(R=>{const T=R.colliders[0];if(T!=null){const V=T.parent,te=W.findIndex(ae=>ae.name===V.name);te!=-1&&(se.includes(te)||se.push(te))}});let he=F((G=N.center)==null?void 0:G.name);he==-1&&console.warn("no center bone for spring bone "+N.name);const me=N.settings;X.push({bones:[j],center:he,colliderGroups:se,dragForce:me.dragForce,gravityDir:{x:me.gravityDir.x,y:me.gravityDir.y,z:me.gravityDir.z},gravityPower:me.gravityPower,hitRadius:me.hitRadius,stiffiness:me.stiffness})});const ue={boneGroups:X,colliderGroups:W};console.log(ue),B.texture=d?_.length-1:void 0;const le=await Promise.all(x.map(async N=>({buffer:s?await K3(N.imageBitmap):$3(N.imageBitmap),type:Kt.IMAGE})));E.forEach((N,j)=>{N.buffer?le.push({buffer:N.buffer,typeString:"",type:N.type}):N.sparse&&(le.push({buffer:N.sparse.indices,typeString:"indices",type:N.type,count:N.sparse.count}),le.push({buffer:N.sparse.values,typeString:"values",type:N.type})),le.length-1}),d&&le.push({buffer:s?await K3(d.imageBitmap):$3(d.imageBitmap),type:Kt.IMAGE});let oe=0,re=0,pe=0,_e=0;const Re=le.map(N=>{const j={buffer:0,byteLength:N.buffer.byteLength,byteOffset:oe,target:N.type===Kt.IMAGE||N.type===Kt.BIND_MATRIX||N.typeString==="indices"||N.typeString==="values"?void 0:N.type===Kt.INDEX?Dn.ELEMENT_ARRAY_BUFFER:Dn.ARRAY_BUFFER};return oe+=N.buffer.byteLength,N.type===Kt.IMAGE?(_[re++].bufferView=_e,_e++):E[pe].sparse?(I[pe].sparse==null&&(I[pe].sparse={}),N.typeString==="indices"&&(I[pe].sparse.count=N.count,I[pe].sparse[N.typeString]={bufferView:_e,byteOffset:0,componentType:Dn.UNSIGNED_INT}),N.typeString==="values"&&(I[pe].sparse[N.typeString]={bufferView:_e,byteOffset:0}),N.typeString==="values"&&pe++,_e++):(E[pe].bufferIndex=_e,I[pe].bufferView=_e,pe++,_e++),j}),Q=Rfe(t,H);bfe(B);const de=["KHR_materials_unlit","KHR_texture_transform","VRM"];s&&de.push("KHR_texture_basisu");const Ae={accessors:I,asset:f,buffers:[{byteLength:oe}],bufferViews:Re,extensions:{VRM:{blendShapeMaster:{blendShapeGroups:u},firstPerson:{firstPersonBone:44,firstPersonBoneOffset:new Z,lookAtHorizontalInner:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtHorizontalOuter:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtTypeName:"Bone",lookAtVerticalDown:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10},lookAtVerticalUp:{curve:[0,0,0,1,1,1,1,0],xRange:90,yRange:10}},materialProperties:O,humanoid:L,meta:B,secondaryAnimation:ue,specVersion:"0.0"}},extensionsUsed:de,images:_,materials:b,meshes:U,nodes:H,samplers:C,scenes:Q,skins:P,textures:S};console.log("output",Ae);const q=new Y3(YC(JSON.stringify(Ae,void 0,2)),"JSON"),J=new Y3(Pp(le.map(N=>N.buffer)),"BIN\0"),ce=Pp([q.buffer,J.buffer]),xe=Pp([YC("glTF"),$C(2,4),$C(ce.byteLength+12,4)]);a(Pp([xe,ce]))}}function bfe(n){n.title=n.title||"Character",n.version=n.version||"1",n.author=n.author||"Anon",n.contactInformation=n.contactInformation||"",n.reference=n.reference||"",n.allowedUserName=n.allowedUserName||"Everyone",n.violentUssageName=n.violentUssageName||"Disallow",n.sexualUssageName=n.sexualUssageName||"Disallow",n.commercialUssageName=n.commercialUssageName||"Disallow",n.otherPermissionUrl=n.otherPermissionUrl||"",n.licenseName=n.licenseName||"Redistribution_Prohibited",n.otherLicenseUrl=n.otherLicenseUrl||""}function S5(n){return n.children.length<=0?[n]:[n].concat(n.children.map(e=>S5(e)).flat())}const Bfe=new gfe;async function K3(n){const e=await createImageBitmap(n),t=document.createElement("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0);const i=r.getImageData(0,0,t.width,t.height),s=new Uint8Array(i.data.buffer);return await Bfe.compress(s,t.width,t.height,4,{normalMap:!1,uastc:!1,qualityLevel:50,compressionLevel:2,uastcFlags:"DEFAULT",compressionUASTC_Rdo_Level:18,uastcRDO:!1,uastcRDOQualityScalar:1,uastcRDODictSize:4096,uastcRDOMaxSmoothBlockErrorScale:10,uastcRDOMaxSmoothBlockStdDev:18,uastcRDODontFavorSimplerModes:!1,ETC1SQualityLevel:128,ETC1SmaxEndpoints:0,ETC1SEndpointRdoThreshold:1.25,ETC1SMaxSelectors:0,ETC1SSelectorRdoThreshold:1.25,ETC1SNoEndpointRdo:!1,ETC1SNoSelectorRdo:!1,supercmp_scheme:"Zstd"})}function $3(n){const e=document.createElement("canvas");e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0);const t=e.toDataURL("image/png"),r=atob(t.split(",")[1]),i=(4-r.length%4)%4,s=new ArrayBuffer(r.length+i),o=new DataView(s);for(let a=0;a4?A=r[a*n.itemSize+l]:l===0?A=n.getX(a):l===1?A=n.getY(a):l===2?A=n.getZ(a):A=n.getW(a),e===Dn.UNSIGNED_SHORT?o.setUint16(i,A,!0):e===Dn.UNSIGNED_INT?o.setUint32(i,A,!0):o.setFloat32(i,A,!0),i+=t}return s}class Y3{constructor(e,t){this.data=e,this.type=t;const r=this.padBuffer(this.data,t==="JSON"?32:0);this.buffer=Pp([$C(r.byteLength,4),YC(this.type),r])}padBuffer(e,t){const r=Math.ceil(e.byteLength/4)*4;if(e.byteLength===r)return e;const i=new ArrayBuffer(r);return new Uint8Array(i).set(new Uint8Array(e)),new Uint8Array(i).fill(t,e.byteLength),i}}const X3=n=>{const e=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],t=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY];for(let r=0;rn.map(r=>{const i=r.type===li.Group?r.children[0]:r,s=r.type===li.Group?r.children.map(o=>o):[r];return{name:r.name,primitives:s.map(o=>{const a=e.map(A=>A.meshName===i.name?A.type:null),l=Array.isArray(o.material)?o.material[0].name:o.material.name;return{attributes:{JOINTS_0:a.indexOf(Kt.SKIN_INDEX),NORMAL:a.indexOf(Kt.NORMAL),POSITION:a.indexOf(Kt.POSITION),TEXCOORD_0:a.indexOf(Kt.UV),WEIGHTS_0:a.indexOf(Kt.SKIN_WEIGHT)},extras:{targetNames:o.geometry.userData.targetNames},indices:e.map(A=>A.type===Kt.INDEX&&A.meshName===i.name?A.name:null).indexOf(o.name),material:t.indexOf(l),mode:4,targets:i.geometry.userData.targetNames?i.geometry.userData.targetNames.map(A=>{const c=e.map(h=>h.type===Kt.BLEND_NORMAL&&h.meshName===i.name?h.name:null).indexOf(KC+A),u=e.map(h=>h.type===Kt.BLEND_POSITION&&h.meshName===i.name?h.name:null).indexOf(KC+A),f={};return u!==-1&&(f.POSITION=u),c!==-1&&(f.NORMAL=c),f}):void 0}})}}),Cfe=(n,e,t)=>n.map(r=>{const i=r.type===li.Group?r.children[0]:r;return{inverseBindMatrices:e.map(s=>s.type===Kt.BIND_MATRIX?s.meshName:null).indexOf(i.name),joints:i.skeleton.bones.map(s=>t.indexOf(s.name)).filter(s=>s!==-1),skeleton:t.indexOf(i.skeleton.bones[0].name)}}),Sfe=(n,e)=>n.map(t=>{let r,i=null;if(t=t.userData.vrmMaterial?t.userData.vrmMaterial:t,t.type==="ShaderMaterial")i={},i.shadeMultiplyTexture={index:e.map(p=>p.name).indexOf(t.uniforms.shadeMultiplyTexture.name)},r=t.color?[1,1,1,1]:void 0;else{const h=t;r=h.color?[h.color.r,h.color.g,h.color.b,1]:void 0}let s=-1;t.map?s=e.map(h=>h.name).indexOf(t.name):t.uniforms&&t.uniforms.map&&(s=e.map(h=>h.name).indexOf(t.uniforms.map.name));let o=-1;t.roughnessMap&&(o=e.map(h=>h.name).indexOf(t.name+"_orm"));let a=-1;t.normalMap&&(a=e.map(h=>h.name).indexOf(t.name+"_normal"));const l=s>=0?{extensions:{KHR_texture_transform:{offset:[0,0],scale:[1,1]}},index:s,texCoord:0}:void 0,A={baseColorFactor:r,baseColorTexture:l},c=o>=0?{index:o,texCoord:0}:void 0,u=a>=0?{index:a,texCoord:0}:void 0;if(c)A.metallicRoughnessTexture=c;else{const h=(()=>{switch(t.type){case Kf.MeshStandardMaterial:return t.metalness;case Kf.MeshBasicMaterial:return 0;default:return 0}})(),p=(()=>{switch(t.type){case Kf.MeshStandardMaterial:return t.roughness;case Kf.MeshBasicMaterial:return .9;default:return .9}})();A.metallicFactor=h,A.roughnessFactor=p}const f={alphaCutoff:t.alphaTest>0?t.alphaTest:void 0,alphaMode:t.transparent?"BLEND":t.alphaTest>0?"MASK":"OPAQUE",doubleSided:t.side===2,extensions:t.type==="ShaderMaterial"?{KHR_materials_unlit:{}}:void 0,name:t.name,pbrMetallicRoughness:A};return u&&(f.normalTexture=u),f}),Mfe=(n,e,t)=>(e?n.concat(e):n).filter(r=>r&&r.imageBitmap).map(r=>({bufferView:-1,mimeType:t,name:r.name})),Tfe=n=>n.map(()=>({magFilter:Dn.LINEAR,minFilter:Dn.LINEAR,wrapS:Dn.REPEAT,wrapT:Dn.REPEAT})),Ife=(n,e)=>e?n.map((t,r)=>({sampler:0,extensions:{KHR_texture_basisu:{source:r}}})):n.map((t,r)=>({sampler:0,source:r})),Rfe=(n,e)=>{const t=e.map(r=>r.name);return[{nodes:n.children.filter(r=>r.type===li.Object3D||r.type===li.SkinnedMesh||r.type===li.Group||r.type===li.Bone).map(r=>t.indexOf(r.name))}]};function Ffe(n,e,t){var a,l;const r=[],i=[];for(const A in n)((l=(a=n[A])==null?void 0:a.vrm)==null?void 0:l.meta)!=null&&(n[A].vrm.meta.authors!=null?i.push(n[A].vrm.meta):r.push(n[A].vrm.meta));r.length+i.length==1&&(r.length==1?r[0].title!=null&&(t=r[0].title):i[0].name!=null&&(t=i[0].name)),e!=null&&(e.authors!=null?i.push(e):r.push(e));const s=Lfe(r),o=Ufe(s,i);return o.licenseUrl="https://vrm.dev/licenses/1.0/",o.name=t,o}function Ufe(n,e){let{authors:t=[],otherLicenseUrl:r=[],contactInformation:i=[],references:s=[],allowExcessivelyViolentUsage:o=void 0,allowExcessivelySexualUsage:a=void 0,commercialUsage:l=void 0,copyrightInformation:A="",avatarPermission:c=void 0,otherPermissionUrl:u=[]}=n,f,h,p,d="unnecessary",g,m=[];e.forEach(b=>{t=t.concat(ct(b.authors)),r=r.concat(ct(b.otherLicenseUrl)),i=i.concat(ct(b.contactInformation)),s=s.concat(ct(b.references)),u=u.concat(ct(b.otherPermissionUrl)),b.allowExcessivelyViolentUsage===!1&&(o=!1),b.allowExcessivelySexualUsage===!1&&(a=!1),l=qa(Ofe,l,b.commercialUsage),A=qa(M5,A,b.copyrightInformation),c=qa(Nfe,c,b.avatarPermission),b.allowAntisocialOrHateUsage===!1&&(f=f=!1),b.allowPoliticalOrReligiousUsage===!1&&(h=h=!1),b.allowRedistribution===!1&&(p=p=!1),b.creditNotation==="required"&&(d="required"),m=m.concat(ct(b.thirdPartyLicenses)),g=qa(Dfe,g,b.modification)});const y=[...new Set(t)].filter(b=>b!=""&&b!=null&&b!="undefined"),w=[...new Set(r)].filter(b=>b!=""&&b!=null&&b!="undefined"),x=[...new Set(i)].filter(b=>b!=""&&b!=null&&b!="undefined"),_=[...new Set(s)].filter(b=>b!=""&&b!=null&&b!="undefined"),C=[...new Set(u)].filter(b=>b!=""&&b!=null&&b!="undefined"),S=[...new Set(m)].filter(b=>b!=""&&b!=null&&b!="undefined");return{authors:y,otherLicenseUrl:w.length==0?"":w.join(", "),contactInformation:x.length==0?"":x.join(", "),references:_,otherPermissionUrl:C.length==0?"":C.join(", "),thirdPartyLicenses:S.length==0?"":S.join(", "),allowExcessivelyViolentUsage:o,allowExcessivelySexualUsage:a,commercialUsage:l,copyrightInformation:A,avatarPermission:c,allowAntisocialOrHateUsage:f,allowPoliticalOrReligiousUsage:h,allowRedistribution:p,creditNotation:d,modification:g}}function Lfe(n){let e=[],t=[],r=[],i=[],s=[],o,a,l,A,c;n.forEach(g=>{e=e.concat(ct(g.author)),t=t.concat(ct(g.contactInformation)),r=r.concat(ct(g.reference)),i=i.concat(ct(g.otherPermissionUrl)),s=s.concat(ct(g.otherLicenseUrl)),o=qa(kfe,o,g.allowedUsername),a=qa(cB,a,g.violentUssageName),l=qa(cB,l,g.sexualUssageName),A=qa(cB,A,g.commercialUssageName),c=qa(M5,c,g.licenseName)});const u=[...new Set(e)].filter(g=>g!=""&&g!=null&&g!="undefined"),f=[...new Set(t)].filter(g=>g!=""&&g!=null&&g!="undefined"),h=[...new Set(r)].filter(g=>g!=""&&g!=null&&g!="undefined"),p=[...new Set(i)].filter(g=>g!=""&&g!=null&&g!="undefined"),d=[...new Set(s)].filter(g=>g!=""&&g!=null&&g!="undefined");return{authors:u,otherLicenseUrl:d,contactInformation:f,references:h,allowExcessivelyViolentUsage:a==="Allow",allowExcessivelySexualUsage:l==="Allow",commercialUsage:A==="Allow"?"personalProfit":"personalNonProfit",copyrightInformation:c,avatarPermission:Pfe(o),otherPermissionUrl:p}}function Pfe(n){if(n=="OnlyAuthor")return"onlyAuthor";if(n=="ExplicitlyLicensedPerson")return"onlySeparatelyLicensedPerson";if(n=="Everyone")return"everyone"}const Dfe={prohibited:0,allowModification:1,allowModificationRedistribution:2},Ofe={personalNonProfit:0,personalProfit:1,corporation:2},Nfe={onlyAuthor:0,onlySeparatelyLicensedPerson:1,everyone:2},kfe={OnlyAuthor:0,ExplicitlyLicensedPerson:1,Everyone:2},cB={Disallow:0,Allow:1},M5={Redistribution_Prohibited:0,Other:1,CC_BY_NC_ND:2,CC_BY_ND:3,CC_BY_NC_SA:4,CC_BY_SA:5,CC_BY_NC:6,CC_BY:7,CC0:8};function qa(n,e,t){return e===void 0?t:t==null||!(t in n)||n[e]{r.userData.origIndexBuffer&&t.push(r.userData.origIndexBuffer)}),e.traverse(r=>{r.userData.origIndexBuffer&&(r.userData.origIndexBuffer=t.shift())}),e}function Qfe(n){const e=T5(n);let t;const r=[];e.traverse(s=>{if(!t&&s.isSkinnedMesh&&(t=m5(s)),s.isSkinnedMesh){if(s.geometry=s.geometry.clone(),s.skeleton=t,r.push(s),Array.isArray(s.material)){const o=s.material;s.material=new kh,s.material.map=o[0].map}s.userData.origIndexBuffer&&s.geometry.setIndex(s.userData.origIndexBuffer)}});const i=new Ur;return r.forEach(s=>{i.add(s)}),i.add(t.bones[0]),i}async function Hfe(n,e,t){const r=await bT(n,t),i=await I5(r,e,t);return new Blob([i],{type:"model/gltf-binary"})}function zfe(n,e,t,r){return new Promise(async(i,s)=>{const o=`${t&&t!==""?t:"AvatarCreatorModel"}`;Gfe(n,e,r).then(a=>{F5(a,`${o}.vrm`),i()})})}async function Gfe(n,e,t){const r=await bT(n,t);return I5(r,e,t)}function bT(n,e){const t=T5(n),{createTextureAtlas:r=!0}=e;return r?Tue(t,e):(console.log("no atlas"),Cue(t,e))}async function Vfe(n,e="",t){const r=`${e&&e!==""?e:"AvatarCreatorModel"}`,{optimized:i=!0}=t,s=i?await bT(n,t):Qfe(n);jfe(s).then(o=>{if(o instanceof ArrayBuffer)F5(o,`${r}.glb`);else{const a=JSON.stringify(o,null,2);Xfe(a,`${r}.gltf`)}})}function jfe(n){return new Promise(e=>new aT().parse(n,r=>{e(r)},r=>{console.error("Error parsing",r)},{trs:!1,onlyVisible:!1,truncateDrawRange:!0,binary:!0,forcePowerOfTwoTextures:!1,maxTextureSize:1024}))}function Wfe(n){var r,i;const e=[];for(const s in n)if(((i=(r=n[s])==null?void 0:r.vrm)==null?void 0:i.springBoneManager)!=null){const o=n[s].vrm.springBoneManager.joints;for(const a of o)e.some(A=>A.name===a.bone.name)||e.push({name:a.bone.name,settings:a.settings,bone:a.bone,colliderGroups:a.colliderGroups,center:a.center})}const t=[];return e.forEach(s=>{for(const o in Km)if(s.bone.parent.name==Km[o]){t.push(s);break}}),t}function Kfe(n){const e={};return n.skeleton.bones.map(t=>{for(const r in Km)if(Km[r]===t.name){e[t.name]={node:t};break}}),e}function $fe(n,e){const t=zh(n,"SkinnedMesh");return{humanBones:Kfe(t[0]),materials:n.userData.atlasMaterial,meta:Yfe(e)}}function Yfe(n){return n=n||{},{...{authors:["CharacterStudio"],metaVersion:"1",version:"v1",name:"CharacterCreator",licenseUrl:"https://vrm.dev/licenses/1.0/",commercialUssageName:"personalNonProfit",contactInformation:"https://m3org.com/",allowExcessivelyViolentUsage:!1,allowExcessivelySexualUsage:!1,allowPoliticalOrReligiousUsage:!1,allowAntisocialOrHateUsage:!1,creditNotation:"required",allowRedistribution:!1,modification:"prohibited"},...n}}function I5(n,e,t){const{screenshot:r=null,isVrm0:i=!1,vrmMeta:s=null,scale:o=1,vrmName:a="CharacterCreator"}=t,l=Ffe(e,s,a);return new Promise(async A=>{const c=i?new _fe:new wce,u={...Jfe(e),...$fe(n,l)};let f;n.traverse(d=>{d.isSkinnedMesh&&(f=d)}),(()=>{for(let d=0;d{d.updateMatrix(),d.updateMatrixWorld()}),f.skeleton.calculateInverses(),f.skeleton.computeBoneTexture(),f.skeleton.update()})(),f.skeleton.bones.filter(d=>d.name==="head")[0];const p=Wfe(e);c.parse(u,n,r,p,t.ktxCompression,o,d=>{A(d)})})}function R5(n,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),t.href=URL.createObjectURL(n),t.download=e,t.click()}function Xfe(n,e){R5(new Blob([n],{type:"text/plain"}),e)}function F5(n,e){R5(Zfe(n),e)}function Zfe(n){return new Blob([n],{type:"application/octet-stream"})}function Jfe(n){for(const e in n)if(n[e].vrm)return n[e].vrm}const qfe=n=>{var e,t;(e=n.parser.json.extensions)!=null&&e.VRM?ehe(n):(t=n.parser.json.extensions)!=null&&t.VRMC_vrm?the(n):console.warn("No valid vrm file was provided")},ehe=n=>{var a,l,A;const e=n.parser.json,t=n.scene,r=e.nodes,i=(A=(l=(a=e.extensions)==null?void 0:a.VRM)==null?void 0:l.secondaryAnimation)==null?void 0:A.colliderGroups,s=[],o=r.map(c=>U5(c.name,s));i!=null&&i.forEach(c=>{const u=o[c.node],f=_5(t,u);if(f!=null){const h=c.colliders;f.userData.VRMcolliders=h.map(p=>({sphere:{radius:p.radius,offset:[p.offset.x,p.offset.y,p.offset.z]}}))}f.userData.VRMcollidersID=w5()})},the=n=>{var l,A,c,u;const e=n.parser.json,t=n.scene,r=e.nodes,i=(A=(l=e.extensions)==null?void 0:l.VRMC_springBone)==null?void 0:A.colliderGroups,s=(u=(c=e.extensions)==null?void 0:c.VRMC_springBone)==null?void 0:u.colliders,o=[],a=r.map(f=>U5(f.name,o));i!=null&&i.forEach(f=>{const h=ct(f.colliders);let p=-1,d=null;h.forEach(g=>{if(p!=s[g].node){p=s[g].node;const m=a[p];d=_5(t,m),d.userData.VRMcolliders=[]}if(d!=null){const m=s[g].shape;for(const y in m){const w=m[y];w!=null&&w.offset&&(w.offset[0]=-w.offset[0])}d.userData.VRMcollidersID=w5(),d.userData.VRMcolliders.push(m)}else console.error("no node with name "+a[p]+" was found")})})},U5=(n,e)=>{const t=_t.sanitizeNodeName(n||"");return t in e?t+"_"+ ++e[t]:(e[t]=0,t)},kw=[0,400,560,2400,4800],Qw=[0,500,700,3e3,6e3],XC=[],Va=[],BT=1024,L5=44100;for(let n=0;n{requestAnimationFrame(t),this.update(r,i)};t()}start(e){this.audioContext=new AudioContext,this.mediaStreamSource=this.audioContext.createMediaStreamSource(e),this.meter=Hw.createAudioMeter(this.audioContext),this.mediaStreamSource.connect(this.meter)}startFromAudioFile(e){this.audioContext||(this.audioContext=new AudioContext),this.userSpeechAnalyzer||(this.userSpeechAnalyzer=this.audioContext.createAnalyser()),this.userSpeechAnalyzer.smoothingTimeConstant=.5,this.userSpeechAnalyzer.fftSize=BT,this.mediaStreamSource&&this.mediaStreamSource.stop(),this.audioContext.decodeAudioData(e).then(t=>{this.mediaStreamSource=this.audioContext.createBufferSource(),this.mediaStreamSource.buffer=t,this.meter=Hw.createAudioMeter(this.audioContext),this.mediaStreamSource.connect(this.meter),this.mediaStreamSource.connect(this.audioContext.destination),this.mediaStreamSource.start(),this.mediaStreamSource.connect(this.userSpeechAnalyzer)})}destroy(){var e,t,r;return(e=this.meter)==null||e.shutdown(),this.meter=null,(t=this.mediaStreamSource)==null||t.disconnect(),((r=this.audioContext)==null?void 0:r.close().catch(()=>{}))||Promise.resolve()}update(e){if(this.meter){const{volume:t}=this.meter;if(t<.01)this.vrm.expressionManager.setValue(oi.Oh,0),this.vrm.expressionManager.setValue(oi.Ah,0),this.vrm.expressionManager.setValue(oi.Ee,0);else{const{ah:r,oh:i,ee:s}=this.update2();this.vrm.expressionManager.setValue(oi.Oh,i),this.vrm.expressionManager.setValue(oi.Ah,r),this.vrm.expressionManager.setValue(oi.Ee,s),this.vrm.expressionManager.update(e)}}}update2(){function e(A){const u=new Float32Array(A.length);for(let f=0;f0&&(i[A]+=r[c]);i[A]/=Va[A+1]-Va[A]}for(let A=0;A0&&(s[A]+=r[c]);i[A]/=Va[A+1]-Va[A],s[A]=s[A]/(XC[A+1]-XC[A])}const o=Math.max(s[1],i[1])>.2?1-2*Math.max(i[2],s[2]):(1-2*Math.max(i[2],s[2]))*5*Math.max(i[1],s[1]),a=3*Math.max(i[3],s[3]),l=.8*(Math.max(i[1],s[1])-Math.max(i[3],s[3]));return{oh:o,ee:l,ah:a}}static createAudioMeter(e){const t=e.createScriptProcessor(512);return t.onaudioprocess=r=>{const i=r.inputBuffer.getChannelData(0),s=i.length;let o=0,a;for(let A=0;A=t.clipLevel&&(t.clipping=!0,t.lastClip=window.performance.now()),o+=a*a;const l=Math.sqrt(o/s);t.volume=Math.max(l,t.volume*t.averaging)},t.clipping=!1,t.lastClip=0,t.volume=0,t.clipLevel=.98,t.averaging=.95,t.clipLag=750,t.connect(e.destination),t.checkClipping=()=>t.clipping?(t.lastClip+t.clipLag{t.disconnect(),t.onaudioprocess=null},t}}const uB=new Z;class nhe{constructor(e,t,r){this.bonesInfo=[],this.curMousePos=new $e,this.hotzoneSection=s(),this.enabled=!1,this.userActivated=!1,this.lookInterest=1,this.hasInterest=!0,this.interestSpeed=.3,this.onCanvas=!0,this.camera=r,this.maxLookPercent={neck:{maxy:15,miny:10,maxx:30,minx:10},spine:{maxy:0,miny:0,maxx:30,minx:10},left:{maxy:15,miny:20,maxx:35,minx:35},right:{maxy:15,miny:20,maxx:35,minx:35}},window.addEventListener("mousemove",o=>{this.curMousePos={x:o.clientX,y:o.clientY}});const i=document.getElementById(t);i&&(i.addEventListener("mouseleave",()=>{this.onCanvas=!1}),i.addEventListener("mouseenter",()=>{this.onCanvas=!0})),window.addEventListener("resize",()=>{this.hotzoneSection=s()});function s(){const o=window.innerWidth*e/100,a=(window.innerWidth-o)/2;return{xStart:a,xEnd:window.innerWidth-a,yStart:50,yEnd:window.innerHeight-80}}}setActive(e){console.log("is activating"),this.userActivated=e}setCamera(e){this.camera=e}addVRM(e){const t=e.data.isVRM0||!1,r=e.humanoid.humanBones;t||(r.neck.node.userData.inverseLookAt=!0,r.spine.node.userData.inverseLookAt=!0,r.leftEye&&(r.leftEye.node.userData.inverseLookAt=!0),r.rightEye&&(r.rightEye.node.userData.inverseLookAt=!0));const i={vrm:e,neckBone:r.neck.node,spineBone:r.spine.node,leftEyeBone:r.leftEye?r.leftEye.node:null,rightEyeBone:r.rightEye?r.rightEye.node:null};this.bonesInfo.push(i)}removeVRM(e){const t=this.bonesInfo.find(r=>r.vrm===e);if(t){const r=this.bonesInfo.indexOf(t);this.bonesInfo.splice(r,1)}}_getMouseDegrees(e,t,r){let i=0,s=0,o,a,l,A,c={x:window.innerWidth,y:window.innerHeight};return e<=c.x/2&&(o=c.x/2-e,a=o/(c.x/2)*100,i=r.maxx*a/100*-1),e>=c.x/2&&(o=e-c.x/2,a=o/(c.x/2)*100,i=r.minx*a/100),t<=c.y/2&&(l=c.y/2-t,A=l/(c.y/2)*100,s=r.maxy*.5*A/100*-1),t>=c.y/2&&(l=t-c.y/2,A=l/(c.y/2)*100,s=r.miny*A/100),{x:i,y:s}}lerp(e,t,r){return(1-r)*e+r*t}_moveJoint(e,t){const r=e.userData.inverseLookAt===!0?1:-1;if(Object.keys(e).length!==0){const i=(this.camera.position.y-1.8)*window.innerHeight/2;let s=this._getMouseDegrees(this.curMousePos.x,this.curMousePos.y-i,t);const o=.8;e.rotation.y=this.lerp(Lt.degToRad(s.x),e.rotation.y,o),e.rotation.x=this.lerp(Lt.degToRad(s.y*r),e.rotation.x,o)}}update(){uB.set(0,0,1),uB.applyQuaternion(this.camera.quaternion);const e=uB.z>0;this.curMousePos.x>this.hotzoneSection.xStart&&this.curMousePos.xthis.hotzoneSection.yStart&&this.curMousePos.y{this._moveJoint(t.neckBone,this.maxLookPercent.neck),this._moveJoint(t.spineBone,this.maxLookPercent.spine),this._moveJoint(t.leftEyeBone,this.maxLookPercent.left),this._moveJoint(t.rightEyeBone,this.maxLookPercent.right)})}}class fB{constructor(e){const{assetsLocation:t,traitsDirectory:r,thumbnailsDirectory:i,traitIconsDirectorySvg:s,animationPath:o,exportScale:a,displayScale:l,initialTraits:A,requiredTraits:c,randomTraits:u,colliderTraits:f,lipSyncTraits:h,blinkerTraits:p,typeRestrictions:d,defaultCullingLayer:g,defaultCullingDistance:m,offset:y,vrmMeta:w,traits:x,textureCollections:_,colorCollections:C,canDownload:S=!0,downloadOptions:b={}}=e;this.assetsLocation=t,this.traitsDirectory=r,this.thumbnailsDirectory=i,this.traitIconsDirectorySvg=s,this.displayScale=l||a||1,this.animationPath=ct(o),this.requiredTraits=ct(c),this.randomTraits=ct(u),this.initialTraits=A||[...new Set(this.requiredTraits.concat(this.randomTraits))],this.colliderTraits=ct(f),this.lipSyncTraits=ct(h),this.blinkerTraits=ct(p),this.typeRestrictions=d,this.defaultCullingLayer=g,this.defaultCullingDistance=m,this.offset=y,this.canDownload=S,this.downloadOptions=b;const M=()=>{const H=[];for(const I in x)H.push(x[I].trait);return H};this.allTraits=M(),M(),(()=>{if(this.typeRestrictions)for(const H in this.typeRestrictions)ct(this.typeRestrictions[H]).forEach(v=>{this.typeRestrictions[v]==null&&(this.typeRestrictions[v]=[]),this.typeRestrictions[v].indexOf(H)==-1&&this.typeRestrictions[v].push(H)})})(),(()=>{b.vrmMeta=b.vrmMeta||w,b.scale=b.scale||a||1,b.mToonAtlasSize=b.mToonAtlasSize||2048,b.mToonAtlasSizeTransp=b.mToonAtlasSizeTransp||1024,b.stdAtlasSize=b.stdAtlasSize||2048,b.stdAtlasSizeTransp=b.stdAtlasSizeTransp||1024,b.exportStdAtlas=b.exportStdAtlas||!1,b.exportMtoonAtlas=b.exportMtoonAtlas||!0,b.screenshotFaceDistance=b.screenshotFaceDistance||1,b.screenshotFaceOffset=b.screenshotFaceOffset||[0,0,0],b.screenshotResolution=b.screenshotResolution||[512,512],b.screenshotBackground=b.screenshotBackground||[.1,.1,.1],b.screenshotFOV=b.screenshotFOV||75,!b.exportStdAtlas&&!b.exportMtoonAtlas&&(b.exportMtoonAtlas=!0)})(),this.textureTraits=[],this.textureTraitsMap=null,this.createTextureTraits(_),this.colorTraits=[],this.colorTraitsMap=null,this.createColorTraits(C),this.modelTraits=[],this.modelTraitsMap=null,this.createModelTraits(x)}appendManifestData(e,t){e.textureTraits.forEach(r=>{const i=this.getTextureGroup(r.trait);i!=null?i.appendCollection(r,t):(this.textureTraits.push(r),this.textureTraitsMap.set(r.trait,r))}),e.colorTraits.forEach(r=>{const i=this.getColorGroup(r.trait);i!=null?i.appendCollection(r,t):(this.colorTraits.push(r),this.colorTraitsMap.set(r.trait,r))}),e.modelTraits.forEach(r=>{const i=this.getModelGroup(r.trait);i!=null?i.appendCollection(r,t):(this.modelTraits.push(r),this.modelTraitsMap.set(r.trait,r))}),console.log(e)}getExportOptions(){return this.downloadOptions}getGroupModelTraits(){return this.modelTraits}getInitialTraits(){return this.getRandomTraits(this.initialTraits)}getAllTraits(){return this.getRandomTraits(this.allTraits)}isColliderRequired(e){return this.colliderTraits.indexOf(e)!=-1}isLipsyncTrait(e){return this.lipSyncTraits.indexOf(e)!=-1}async getNFTraitOptionsFromURL(e,t){const r=await this._fetchJson(e);return this.getNFTraitOptionsFromObject(r,t)}getNFTraitOptionsFromObject(e,t){const r=e.attributes;if(r){t=ct(t);const i=[];return r.forEach(s=>{if(t.indexOf(s.trait_type)==-1){const o=this.getTraitOption(s.trait_type,s.value);o&&i.push(o)}}),i}else return console.warn("No attiributes parameter was found in ",e),null}getRandomTraits(e){const t=[];return(e||this.randomTraits).forEach(i=>{const s=this.getRandomTrait(i);s&&t.push(s)}),this._filterTraitOptions(t)}getRandomTrait(e){var r,i;const t=this.getModelGroup(e);if(t){const s=t.getRandomTrait();if(s){const o=(r=s.targetTextureCollection)==null?void 0:r.getRandomTrait(),a=(i=s.targetColorCollection)==null?void 0:i.getRandomTrait();return new hB(s,o,a)}else return null}else return console.warn("No trait group with name "+e+" was found."),null}async _fetchJson(e){return await(await fetch(e)).json()}getTraitOption(e,t){var i,s;const r=this.getModelTrait(e,t);if(r){const o=(i=r.targetTextureCollection)==null?void 0:i.getRandomTrait(),a=(s=r.targetColorCollection)==null?void 0:s.getRandomTrait();return new hB(r,o,a)}return null}_filterTraitOptions(e){const t=[],r=[];for(let i=0;i0&&console.log("options were filtered to fullfill restrictions: ",r),t}getCustomTraitOption(e,t){const r=this.getCustomModelTrait(e,t);return r?new hB(r,null,null):null}getCustomModelTrait(e,t){var r;return(r=this.getModelGroup(e))==null?void 0:r.getCustomTrait(t)}getModelTrait(e,t){var r;return(r=this.getModelGroup(e))==null?void 0:r.getTrait(t)}getModelTraits(e){const t=this.getModelGroup(e);return t?t.getCollection():(console.warn("No model group with name "+e),null)}getModelGroup(e){return this.modelTraitsMap.get(e)}getTextureTrait(e,t){var r;return(r=this.getTextureGroup(e))==null?void 0:r.getTrait(t)}getTextureGroup(e){return this.textureTraitsMap.get(e)}getColorTrait(e,t){var r;return(r=this.getColorGroup(e))==null?void 0:r.getTrait(t)}getColorGroup(e){return this.colorTraitsMap.get(e)}getTraitsDirectory(){let e=(this.assetsLocation||"")+(this.traitsDirectory||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getThumbnailsDirectory(){let e=(this.assetsLocation||"")+(this.thumbnailsDirectory||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getTraitIconsDirectorySvg(){let e=(this.assetsLocation||"")+(this.traitIconsDirectorySvg||"");return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}getAssetsDirectory(){let e=this.assetsLocation||"";return!e.endsWith("/")&&!e.endsWith("\\")&&(e+="/"),e}createModelTraits(e,t=!1){t&&(this.modelTraits=[]),ct(e).forEach(r=>{this.modelTraits.push(new rhe(this,r))}),this.modelTraitsMap=new Map(this.modelTraits.map(r=>[r.trait,r])),this.modelTraits.forEach(r=>{r.restrictedTraits.forEach(i=>{const s=this.getModelGroup(i);console.log(s),s&&s.addTraitRestriction(r.trait)})})}createTextureTraits(e,t=!1){t&&(this.textureTraits=[]),ct(e).forEach(r=>{this.textureTraits.push(new ihe(this,r))}),this.textureTraitsMap=new Map(this.textureTraits.map(r=>[r.trait,r]))}createColorTraits(e,t=!1){t&&(this.colorTraits=[]),ct(e).forEach(r=>{this.colorTraits.push(new she(this,r))}),this.colorTraitsMap=new Map(this.colorTraits.map(r=>[r.trait,r]))}}class rhe{constructor(e,t){const{trait:r,name:i,iconSvg:s,cameraTarget:o={distance:3,height:1},cullingDistance:a,cullingLayer:l,collection:A,restrictedTraits:c=[],restrictedTypes:u=[]}=t;this.manifestData=e,this.isRequired=e.requiredTraits.indexOf(r)!==-1,this.trait=r,this.name=i,this.iconSvg=s,this.fullIconSvg=e.getTraitIconsDirectorySvg()+s,this.restrictedTraits=c,this.restrictedTypes=u,this.cameraTarget=o,this.cullingDistance=a,this.cullingLayer=l,this.collection=[],this.collectionMap=null,this.createCollection(A)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Model with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Model with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}addTraitRestriction(e){this.restrictedTraits.indexOf(e)==-1&&this.restrictedTraits.push(e)}createCollection(e,t=!1){t&&(this.collection=[]),ct(e).forEach(r=>{this.collection.push(new Z3(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getCustomTrait(e){return new Z3(this,{directory:e,fullDirectory:e,id:"_custom",name:"Custom"})}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}getCollection(){return this.collection}}class ihe{constructor(e,t){const{trait:r,collection:i}=t;this.manifestData=e,this.trait=r,this.collection=[],this.collectionMap=null,this.createCollection(i)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Texture with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Texture with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}createCollection(e,t=!1){t&&(this.collection=[]),ct(e).forEach(r=>{this.collection.push(new ohe(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}}class she{constructor(e,t){const{trait:r,collection:i}=t;this.manifestData=e,this.trait=r,this.collection=[],this.collectionMap=null,this.createCollection(i)}appendCollection(e,t){e.collection.forEach(r=>{const i=this.getTrait(r.id);if(i!=null)if(t){console.log(`Color with id ${r.id} exists and will be replaced with new one`),this.collectionMap.set(r.id,r);const s=this.collection.indexOf(i);this.collection[s]=r}else console.log(`Color with id ${r.id} exists, skipping`);else this.collection.push(r),this.collectionMap.set(r.id,r)})}createCollection(e,t=!1){t&&(this.collection=[]),ct(e).forEach(r=>{this.collection.push(new ahe(this,r))}),this.collectionMap=new Map(this.collection.map(r=>[r.id,r]))}getTrait(e){return this.collectionMap.get(e)}getTraitByIndex(e){return this.collection[e]}getRandomTrait(){return this.collection.length>0?this.collection[Math.floor(Math.random()*this.collection.length)]:null}}class Z3{constructor(e,t){const{id:r,directory:i,name:s,thumbnail:o,cullingDistance:a,cullingLayer:l,type:A=[],textureCollection:c,colorCollection:u,fullDirectory:f,fullThumbnail:h}=t;if(this.manifestData=e.manifestData,this.traitGroup=e,this.id=r,this.directory=i,f)this.fullDirectory=f;else if(Array.isArray(i)){this.fullDirectory=[];for(let p=0;p0&&this.manifestData.restrictedTypes>0){haveCommonValue=(i,s)=>{if(i==null||s==null)return!1;for(let o=0;ohaveCommonValue(r[i],traitTypes))}return!1}}class ohe{constructor(e,t){const{id:r,directory:i,fullDirectory:s,name:o,thumbnail:a}=t;if(this.traitGroup=e,this.id=r,this.directory=i,s)this.fullDirectory=s;else if(Array.isArray(i)){this.fullDirectory=[];for(let l=0;l{o.isSkinnedMesh&&o.skeleton.bones.filter(l=>l.name==="head")[0].getWorldPosition(Qa)}),Qa.z+=.3,Qa.y+=s,this.screenshotManager.setCamera(Qa,i),this.screenshotManager.saveScreenshot(e,t,r),this.blinkManager.disableScreenshot()}cameraRaycastCulling(e,t,r=!0){if(this.renderCamera==null){console.warn("No camera was set in character manager. Please call setRenderCamera(camera) before calling this function");return}const i=()=>{this.characterModel.traverse(A=>{A.isMesh&&A.userData.origIndexBuffer&&(A.userData.clippedIndexGeometry=A.geometry.index.clone(),A.geometry.setIndex(A.userData.origIndexBuffer))})},s=()=>{this.characterModel.traverse(A=>{A.isMesh&&A.userData.origIndexBuffer&&A.geometry.setIndex(A.userData.clippedIndexGeometry)})},o=(A,c)=>{for(let u=0;u{var d,g;const u=A.object,f=A.face,h=[f.a,f.b,f.c],p=(g=(d=u.userData)==null?void 0:d.clippedIndexGeometry)==null?void 0:g.array;if(p!=null){const m=o(p,h),y=Array.from(p);if(m==-1&&!c){const w=[...y,...h];u.userData.clippedIndexGeometry=new At(new Uint32Array(w),1,!1)}m!=1&&c&&(y.splice(m,3),u.userData.clippedIndexGeometry=new At(new Uint32Array(y),1,!1))}};dB.x=e,dB.y=t,i(),J3.setFromCamera(dB,this.renderCamera);const l=J3.intersectObjects(this.characterModel.children);if(l.length>0){const A=l[0];a(A,r)}s()}removeCurrentCharacter(){const e=[];for(const t in this.avatar)e.push(new gy({traitGroupID:t,traitModel:null}));e.forEach(t=>{this._addLoadedData(t)}),this.avatar={}}removeCurrentManifest(){this.removeCurrentCharacter(),this.manifest=null,this.manifestData=null,this.animationManager&&this.animationManager.clearCurrentAnimations()}canDownload(){var e;return((e=this.manifestData)==null?void 0:e.canDownload)||!0}downloadVRM(e,t=null){return new Promise(async(r,i)=>{if(this.canDownload())try{t=t||{};const o={...this.manifestData.getExportOptions(),...t};o.isVrm0=!0,o.screenshot=this._getPortaitScreenshotTexture(!1,o),console.log(o),await zfe(this.characterModel,this.avatar,e,o),r()}catch(s){console.error("Error downloading VRM:",s.message),i(new Error("Failed to download VRM."))}else{const s="Download not supported.";console.error(s),i(new Error(s))}})}downloadGLB(e,t=null){if(console.log("XXX fix glb downloader"),this.canDownload()){t=t||{};const r={...this.manifestData.getExportOptions(),...t};Vfe(this.characterModel,e,r)}else console.error("Download not supported")}getAvatarSelection(){var t;var e={};for(const r in this.avatar)e[r]={name:this.avatar[r].name,id:(t=this.avatar[r].traitInfo)==null?void 0:t.id};return e}getBoneTriangleCount(){let e=0,t=new Set;for(const r in this.avatar)this.avatar[r].model.traverse(i=>{i.isMesh&&(e+=i.geometry.index.array.length),i.isSkinnedMesh&&i.skeleton.bones.forEach(s=>{t.add(s.name)})});return{triangles:e/3,bones:t.size}}getGroupTraits(){if(this.manifestData)return this.manifestData.getGroupModelTraits()}getCurrentCharacterModel(){return this.characterModel}isTraitGroupRequired(e){const t=this.manifestData.getModelGroup(e);return!!(t!=null&&t.isRequired)}getTraits(e){return this.manifestData?this.manifestData.getModelTraits(e):(console.warn("No manifest file has been loaded, please load it before trait models."),null)}getCurrentTraitID(e){var t,r;return(r=(t=this.avatar[e])==null?void 0:t.traitInfo)==null?void 0:r.id}getCurrentTraitData(e){var t;return(t=this.avatar[e])==null?void 0:t.traitInfo}getCurrentTraitVRM(e){var t;return(t=this.avatar[e])==null?void 0:t.vrm}setParentModel(e){e.add(this.rootModel),this.parentModel=e,this.screenshotManager&&this.screenshotManager.setScene(this.parentModel)}setRenderCamera(e){this.renderCamera=e}loadRandomTraits(){return new Promise(async(e,t)=>{if(this.manifestData){const r=this.manifestData.getRandomTraits();await this._loadTraits(r),e()}else{const r="No manifest was loaded, random traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadRandomTrait(e){return new Promise(async(t,r)=>{if(this.manifestData){const i=this.manifestData.getRandomTrait(e);await this._loadTraits(ct(i)),t()}else{const i="No manifest was loaded, random traits cannot be loaded.";console.error(i),r(new Error(i))}})}loadTraitsFromNFT(e,t=!0,r=null){return new Promise(async(i,s)=>{try{if(this.manifestData){const o=this.manifestData.getNFTraitOptionsFromURL(e,r);await this._loadTraits(o,t),i()}else{const o="No manifest was loaded, NFT traits cannot be loaded.";console.error(o),s(new Error(o))}}catch(o){s(o)}})}loadTraitsFromNFTObject(e,t=!0,r=null){return new Promise(async(i,s)=>{if(this.manifestData)try{const o=this.manifestData.getNFTraitOptionsFromObject(e,r);await this._loadTraits(o,t),i()}catch(o){console.error("Error loading traits from NFT object:",o.message),s(new Error("Failed to load traits from NFT object."))}else{const o="No manifest was loaded, NFT traits cannot be loaded.";console.error(o),s(new Error(o))}})}loadInitialTraits(){return new Promise(async(e,t)=>{if(this.manifestData)await this._loadTraits(this.manifestData.getInitialTraits()),e();else{const r="No manifest was loaded, initial traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadAllTraits(){return console.log("load all"),new Promise(async(e,t)=>{if(this.manifestData)await this._loadTraits(this.manifestData.getAllTraits()),e();else{const r="No manifest was loaded, initial traits cannot be loaded.";console.error(r),t(new Error(r))}})}loadTrait(e,t,r=!1){return new Promise(async(i,s)=>{if(this.manifestData)try{const o=this.manifestData.getTraitOption(e,t);o&&(await this._loadTraits(ct(o),r),i())}catch(o){console.error("Error loading specific trait:",o.message),s(new Error("Failed to load specific trait."))}else{const o="No manifest was loaded, specific trait cannot be loaded.";console.error(o),s(new Error(o))}})}loadCustomTrait(e,t){return new Promise(async(r,i)=>{if(this.manifestData)try{const s=this.manifestData.getCustomTraitOption(e,t);s&&(await this._loadTraits(ct(s)),r())}catch(s){console.error("Error loading custom trait:",s.message),i(new Error("Failed to load custom trait."))}else{const s="No manifest was loaded, custom trait cannot be loaded.";console.error(s),i(new Error(s))}})}loadCustomTexture(e,t){return new Promise(async(r,i)=>{var o;const s=(o=this.avatar[e])==null?void 0:o.model;if(s)await Pue(s,t),r();else{const a="No Group Trait with name "+e+" was found.";console.warn(a),i(new Error(a))}})}setTraitColor(e,t){var i;const r=(i=this.avatar[e])==null?void 0:i.model;if(r)try{const s=new Qe(t);r.traverse(o=>{o.isMesh&&(o.material.type==="MeshStandardMaterial"?Array.isArray(o.material)?o.material.forEach(a=>{a.color=s}):o.material.color=s:(o.material[0].uniforms.litFactor.value=s,o.material[0].uniforms.shadeColorFactor.value=new Qe(s.r*.8,s.g*.8,s.b*.8)))})}catch(s){throw console.error("Error setting trait color:",s.message),new Error("Failed to set trait color.")}else{const s="No Group Trait with name "+e+" was found.";throw console.warn(s),new Error(s)}}removeTrait(e,t=!1){if(this.isTraitGroupRequired(e)&&!t){console.warn(`No trait with name: ${e} is not removable.`);return}if(this.manifestData.getModelGroup(e)){const i=new gy({traitGroupID:e,traitModel:null});this._addLoadedData(i),oB(this.avatar)}else console.warn(`No trait with name: ${e} was found.`)}updateCullHiddenMeshes(){oB(this.avatar)}loadOptimizerManifest(){this.manifest={colliderTraits:["CUSTOM"],traits:[{name:"Custom",trait:"CUSTOM",collection:[]}]},this.manifestData=new fB(this.manifest)}getCurrentOptimizerCharacterModel(){var e;return(e=this.avatar.CUSTOM)==null?void 0:e.vrm}loadOptimizerCharacter(e){return this.loadCustomTrait("CUSTOM",e)}setManifest(e){return this.removeCurrentCharacter(),new Promise(async(t,r)=>{try{if(this.manifest=e,this.manifest){if(this.manifestData=new fB(this.manifest),this.animationManager)try{await this._animationManagerSetup(this.manifest.animationPath,this.manifest.assetsLocation,this.manifestData.displayScale)}catch(i){console.error("Error loading animations: "+i)}t()}else{const i="Failed to fetch or parse the manifest.";console.error(i),r(new Error(i))}}catch(i){console.error("Error setting manifest:",i.message),r(new Error("Failed to set the manifest."))}})}appendManifest(e,t){return new Promise(async(r,i)=>{try{t?this.manifest={...this.manifest||{},manifest:e}:this.manifest={manifest:e,...this.manifest||{}};const s=new fB(e);this.manifestData.appendManifestData(s),r()}catch(s){console.error("Error setting manifest:",s.message),i(new Error("Failed to set the manifest."))}})}loadManifest(e){return new Promise(async(t,r)=>{try{const i=await this._fetchManifest(e);this.setManifest(i).then(()=>{t()})}catch(i){console.error("Error loading manifest:",i.message),r(new Error("Failed to load the manifest."))}})}loadAppendManifest(e,t){return new Promise(async(r,i)=>{try{const s=await this._fetchManifest(e);this.appendManifest(s,t).then(()=>{r()})}catch(s){console.error("Error loading manifest:",s.message),i(new Error("Failed to load the manifest."))}})}async soloTargetGroupTrait(e){const t=ct(e),r=[];for(const i in this.avatar)t.includes(i)&&r.push(this.manifestData.getTraitOption(i,this.avatar[i].traitInfo.id));await this._loadTraits(r,!0)}storeCurrentAvatar(){this.storedAvatar={...this.avatar}}async loadStoredAvatar(){const e=[];for(const t in this.storedAvatar)e.push(this.manifestData.getTraitOption(t,this.storedAvatar[t].traitInfo.id));console.log(e),this._loadTraits(e,!0)}async _loadTraits(e,t=!1){console.log("laoded traits:",e),await this.traitLoadManager.loadTraitOptions(ct(e)).then(r=>{t&&this.getGroupTraits().forEach(s=>{r.some(a=>{var l;return((l=a.traitModel)==null?void 0:l.traitGroup.trait)===s.trait})||this.avatar[s.trait]!=null&&r.push(new gy({traitGroupID:s.trait,traitModel:null}))}),r.forEach(i=>{this._addLoadedData(i)}),oB(this.avatar)})}async _animationManagerSetup(e,t,r){const i=ct(e);this.animationManager&&(this.animationManager.setScale(r),e.length>0&&(this.animationManager.storeAnimationPaths(i,t||""),await this.animationManager.loadAnimation(i,!1,0,i[0].endsWith(".fbx"),t||"")))}async _fetchManifest(e){return await(await fetch(e)).json()}_getPortaitScreenshotTexture(e,t){this.blinkManager.enableScreenshot(),this.characterModel.traverse(u=>{u.isSkinnedMesh&&u.skeleton.bones.filter(h=>h.name==="head")[0].getWorldPosition(Qa)});const{screenshotResolution:r,screenshotFaceDistance:i,screenshotFaceOffset:s,screenshotBackground:o,screenshotFOV:a}=t,l=r[0],A=r[1];Qa.x+=s[0],Qa.y+=s[1],Qa.z+=s[2],this.screenshotManager.setBackground(o),this.screenshotManager.setCamera(Qa,i,a);const c=e?this.screenshotManager.getScreenshotBlob(l,A):this.screenshotManager.getScreenshotTexture(l,A);return this.blinkManager.disableScreenshot(),c}_setupWireframeMaterial(e){e.origMat=e.material;const t=()=>{const o=.1+Math.random()*.9,a=.1+Math.random()*(1-.1),l=.1+Math.random()*(1-.1);return new Qe(o,a,l)},r=new Ei({color:t(),wireframe:!0,wireframeLinewidth:.2}),i=e.material;e.setDebugMode=s=>{s?e.material.length?(e.material[0]=r,e.material[1]=r):e.material=r:e.material=i}}_VRMBaseSetup(e,t,r,i,s){var a,l;let o=e.userData.vrm;if(e.userData.vrm==null)return console.error("No valid VRM was provided for "+r+" trait, skipping file."),null;if(k3(o,{isVRM0:((a=o.meta)==null?void 0:a.metaVersion)==="0"}),this.manifestData.isColliderRequired(r)&&qfe(e),Hue(o),this.manifestData.isLipsyncTrait(r)&&(this.lipSync=new Hw(o)),this._modelBaseSetup(o,t,r,i,s),((l=o.meta)==null?void 0:l.metaVersion)==="0"){if(o.humanoid.humanBones.hips.node.parent==o.scene){const A=new It;A.name="newRootNode",Lue(o.scene,A),A.add(o.humanoid.humanBones.hips.node)}o.humanoid.humanBones.hips.node.parent.rotateY(3.14159),o.scene.traverse(A=>{var c;if(A.isSkinnedMesh){const u={},f=ct((c=A.geometry.userData)==null?void 0:c.targetNames);for(let h=0;h{const f=e.scene.getObjectByName(u);f!=null&&f.isMesh&&o.push(f)}),e.scene.traverse(u=>{!t.meshTargets&&u.isMesh&&o.push(u),u.frustumCulled=!1,u.isMesh&&(this._setupWireframeMaterial(u),a.indexOf(u.name)===-1&&l.push(u))});const A=this.manifest,c=this.manifestData.getModelGroup(r);k3(e,{cullingLayer:t.cullingLayer!=null?t.cullingLayer:c.cullingLayer!=null?c.cullingLayer:A.defaultCullingLayer!=null?A.defaultCullingLayer:-1,cullingDistance:t.cullingDistance!=null?t.cullingDistance:c.cullingDistance!=null?c.cullingDistance:A.defaultCullingDistance!=null?A.defaultCullingDistance:null,maxCullingDistance:t.maxCullingDistance!=null?t.maxCullingDistance:c.maxCullingDistance!=null?c.maxCullingDistance:A.maxCullingDistance!=null?A.maxCullingDistance:1/0,cullingMeshes:l}),o.map((u,f)=>{if(i){const h=i[f]||i[0];h!=null&&ct(u.material).map(p=>{che(p,h)})}if(s){const h=s[f]||s[0];h!=null&&(u.material[0].uniforms.litFactor.value=h,u.material[0].uniforms.shadeColorFactor.value=new Qe(h.r*.8,h.g*.8,h.b*.8))}})}_applyManagers(e){this.blinkManager.addVRM(e),this.lookAtManager&&this.lookAtManager.addVRM(e),this.animationManager&&this.animationManager.addVRM(e)}_displayModel(e){if(e){const t=e.scene;this.characterModel.attach(t)}}_positionModel(e){const t=this.manifestData.displayScale;e.scene.scale.set(t,t,t)}_disposeTrait(e){this.blinkManager.removeVRM(e),this.lookAtManager&&this.lookAtManager.removeVRM(e),this.animationManager&&this.animationManager.removeVRM(e),Que(e)}_addLoadedData(e){const{traitGroupID:t,traitModel:r,textureTrait:i,colorTrait:s,models:o,textures:a,colors:l}=e;if(r==null){this.avatar[t]&&this.avatar[t].vrm&&(this._disposeTrait(this.avatar[t].vrm),this.avatar[t]={});return}let A=null;o.map(c=>{c!=null&&(A=this._VRMBaseSetup(c,r,t,a,l))}),A!=null&&(this.avatar[t]&&this.avatar[t].vrm&&this._disposeTrait(this.avatar[t].vrm),this._positionModel(A),this._displayModel(A),this._applyManagers(A),console.log(this.characterModel),this.avatar[t]={traitInfo:r,textureInfo:i,colorInfo:s,name:r.name,model:A&&A.scene,vrm:A})}}class Ahe{constructor(){const e=new UH;e.onProgress=(i,s,o)=>{this.setLoadPercentage(Math.round(s/o*100))};const t=new QH(e);t.crossOrigin="anonymous",t.register(i=>new dce(i,{autoUpdateHumanBones:!0}));const r=new lu(e);this.loadPercentager=0,this.loadingManager=e,this.gltfLoader=t,this.textureLoader=r,this.isLoading=!1}setLoadPercentage(e){this.loadPercentager=e}loadTraitOptions(e){return new Promise(t=>{this.isLoading=!0;const r=[],i=e.map(async(s,o)=>{var c,u,f;if(s==null){r[o]=null;return}const a=await Promise.all(ct((c=s==null?void 0:s.traitModel)==null?void 0:c.fullDirectory).map(async h=>{try{return await this.gltfLoader.loadAsync(h)}catch(p){return console.error(`Error loading modelsss ${h}:`,p),null}})),l=await Promise.all(ct((u=s==null?void 0:s.traitTexture)==null?void 0:u.fullDirectory).map(h=>new Promise(p=>{this.textureLoader.load(h,d=>{d.flipY=!1,d.encoding=pt,p(d)},null,d=>{console.error("error loading texture: ",d),p(null)})}))),A=ct((f=s==null?void 0:s.traitColor)==null?void 0:f.value).map(h=>new Qe(h));r[o]=new gy({traitGroupID:s==null?void 0:s.traitModel.traitGroup.trait,traitModel:s==null?void 0:s.traitModel,textureTrait:s==null?void 0:s.traitTexture,colorTrait:s==null?void 0:s.traitColor,models:a,textures:l,colors:A})});Promise.allSettled(i).then(()=>{this.setLoadPercentage(100),t(r),this.isLoading=!1}).catch(s=>{this.setLoadPercentage(100),console.error("An error occurred:",s),t(r),this.isLoading=!1})})}}class gy{constructor(e){const{traitGroupID:t,traitModel:r,textureTrait:i,colorTrait:s,models:o,textures:a,colors:l}=e;this.traitGroupID=t,this.traitModel=r,this.textureTrait=i,this.colorTrait=s,this.models=o,this.textures=a,this.colors=l}}function che(n,e){if(n.type==="Shadermaterial"&&!n.isMToonMaterial){console.warn("XXX set material texture to shader material",n);return}n.map=e,n.needsUpdate=!0}function uhe(n){const e=new vw,t=new DH(16777215,.5);e.add(t);const r=new iT(16777215,.5);r.position.set(0,1,1),e.add(r);const i=new It;e.add(i);const s=new Fr(30,window.innerWidth/window.innerHeight,.1,1e3);s.position.set(0,1.3,2);const o=new lhe({parentModel:e,createAnimationManager:!0,renderCamera:s});o.addLookAtMouse(80,n,s,!0);const a=document.getElementById(n),l=new vg({canvas:a,antialias:!0,alpha:!0,preserveDrawingBuffer:!0}),A=new one(s,l.domElement);A.minDistance=1,A.maxDistance=4,A.maxPolarAngle=Math.PI/2,A.enablePan=!0,A.target=new Z(0,1,0),A.enableDamping=!0,A.dampingFactor=.1;const c=new Z(-.5,0,-.5),u=new Z(.5,1.5,.5),f=()=>{l.setSize(window.innerWidth,window.innerHeight),s.aspect=window.innerWidth/window.innerHeight,s.updateProjectionMatrix()};window.addEventListener("resize",f),l.setSize(window.innerWidth,window.innerHeight),l.setPixelRatio(window.devicePixelRatio),l.outputEncoding=pt;const h=()=>{requestAnimationFrame(h),A.target.clamp(c,u),A==null||A.update(),o.update(),l.render(e,s)};h();const p=g=>{const m=g.ctrlKey,y=a.getBoundingClientRect(),w=(g.clientX-y.left)/y.width*2-1,x=-((g.clientY-y.top)/y.height)*2+1;o.cameraRaycastCulling(w,x,m)};async function d(){}return d(),a.addEventListener("click",p),{scene:e,camera:s,controls:A,characterManager:o,sceneElements:i}}function xv(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var P5={exports:{}};/*! JSZip v3.10.1 - A JavaScript class for generating and reading zip files @@ -4220,7 +4220,7 @@ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/js JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/main/LICENSE */(function(n,e){(function(t){n.exports=t()})(function(){return function t(r,i,s){function o(A,c){if(!i[A]){if(!r[A]){var u=typeof xv=="function"&&xv;if(!c&&u)return u(A,!0);if(a)return a(A,!0);var f=new Error("Cannot find module '"+A+"'");throw f.code="MODULE_NOT_FOUND",f}var h=i[A]={exports:{}};r[A][0].call(h.exports,function(p){var d=r[A][1][p];return o(d||p)},h,h.exports,t,r,i,s)}return i[A].exports}for(var a=typeof xv=="function"&&xv,l=0;l>2,h=(3&A)<<4|c>>4,p=1>6:64,d=2>4,c=(15&f)<<4|(h=a.indexOf(l.charAt(d++)))>>2,u=(3&h)<<6|(p=a.indexOf(l.charAt(d++))),y[g++]=A,h!==64&&(y[g++]=c),p!==64&&(y[g++]=u);return y}},{"./support":30,"./utils":32}],2:[function(t,r,i){var s=t("./external"),o=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function A(c,u,f,h,p){this.compressedSize=c,this.uncompressedSize=u,this.crc32=f,this.compression=h,this.compressedContent=p}A.prototype={getContentWorker:function(){var c=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return c.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),c},getCompressedWorker:function(){return new o(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},A.createWorkerFrom=function(c,u,f){return c.pipe(new a).pipe(new l("uncompressedSize")).pipe(u.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},r.exports=A},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,r,i){var s=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,r,i){var s=t("./utils"),o=function(){for(var a,l=[],A=0;A<256;A++){a=A;for(var c=0;c<8;c++)a=1&a?3988292384^a>>>1:a>>>1;l[A]=a}return l}();r.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?function(A,c,u,f){var h=o,p=f+u;A^=-1;for(var d=f;d>>8^h[255&(A^c[d])];return-1^A}(0|l,a,a.length,0):function(A,c,u,f){var h=o,p=f+u;A^=-1;for(var d=f;d>>8^h[255&(A^c.charCodeAt(d))];return-1^A}(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(t,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,r,i){var s=null;s=typeof Promise<"u"?Promise:t("lie"),r.exports={Promise:s}},{lie:37}],7:[function(t,r,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),A=s?"uint8array":"array";function c(u,f){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=f,this.meta={}}i.magic="\b\0",a.inherits(c,l),c.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(A,u.data),!1)},c.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(f){u.push({data:f,meta:u.meta})}},i.compressWorker=function(u){return new c("Deflate",u)},i.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,r,i){function s(h,p){var d,g="";for(d=0;d>>=8;return g}function o(h,p,d,g,m,y){var w,x,_=h.file,C=h.compression,S=y!==A.utf8encode,b=a.transformTo("string",y(_.name)),M=a.transformTo("string",A.utf8encode(_.name)),D=_.comment,$=a.transformTo("string",y(D)),H=a.transformTo("string",A.utf8encode(D)),I=M.length!==_.name.length,v=H.length!==D.length,E="",U="",P="",L=_.dir,z=_.date,K={crc32:0,compressedSize:0,uncompressedSize:0};p&&!d||(K.crc32=h.crc32,K.compressedSize=h.compressedSize,K.uncompressedSize=h.uncompressedSize);var O=0;p&&(O|=8),S||!I&&!v||(O|=2048);var B=0,W=0;L&&(B|=16),m==="UNIX"?(W=798,B|=function(F,X){var ue=F;return F||(ue=X?16893:33204),(65535&ue)<<16}(_.unixPermissions,L)):(W=20,B|=function(F){return 63&(F||0)}(_.dosPermissions)),w=z.getUTCHours(),w<<=6,w|=z.getUTCMinutes(),w<<=5,w|=z.getUTCSeconds()/2,x=z.getUTCFullYear()-1980,x<<=4,x|=z.getUTCMonth()+1,x<<=5,x|=z.getUTCDate(),I&&(U=s(1,1)+s(c(b),4)+M,E+="up"+s(U.length,2)+U),v&&(P=s(1,1)+s(c($),4)+H,E+="uc"+s(P.length,2)+P);var ee="";return ee+=` -\0`,ee+=s(O,2),ee+=C.magic,ee+=s(w,2),ee+=s(x,2),ee+=s(K.crc32,4),ee+=s(K.compressedSize,4),ee+=s(K.uncompressedSize,4),ee+=s(b.length,2),ee+=s(E.length,2),{fileRecord:u.LOCAL_FILE_HEADER+ee+b+E,dirRecord:u.CENTRAL_FILE_HEADER+s(W,2)+ee+s($.length,2)+"\0\0\0\0"+s(B,4)+s(g,4)+b+E+$}}var a=t("../utils"),l=t("../stream/GenericWorker"),A=t("../utf8"),c=t("../crc32"),u=t("../signature");function f(h,p,d,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=p,this.zipPlatform=d,this.encodeFileName=g,this.streamFiles=h,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(h){var p=h.meta.percent||0,d=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(h):(this.bytesWritten+=h.data.length,l.prototype.push.call(this,{data:h.data,meta:{currentFile:this.currentFile,percent:d?(p+100*(d-g-1))/d:100}}))},f.prototype.openedSource=function(h){this.currentSourceOffset=this.bytesWritten,this.currentFile=h.file.name;var p=this.streamFiles&&!h.file.dir;if(p){var d=o(h,p,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:d.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(h){this.accumulate=!1;var p=this.streamFiles&&!h.file.dir,d=o(h,p,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(d.dirRecord),p)this.push({data:function(g){return u.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)}(h),meta:{percent:100}});else for(this.push({data:d.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var h=this.bytesWritten,p=0;p=this.index;l--)A=(A<<8)+this.byteAt(l);return this.index+=a,A},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=o},{"../utils":32}],19:[function(t,r,i){var s=t("./Uint8ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,r,i){var s=t("./DataReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(t,r,i){var s=t("./ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(t,r,i){var s=t("../utils"),o=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),A=t("./NodeBufferReader"),c=t("./Uint8ArrayReader");r.exports=function(u){var f=s.getTypeOf(u);return s.checkSupport(f),f!=="string"||o.uint8array?f==="nodebuffer"?new A(u):o.uint8array?new c(s.transformTo("uint8array",u)):new a(s.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,r,i){var s=t("./GenericWorker"),o=t("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,r,i){var s=t("./GenericWorker"),o=t("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,r,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,o),a.prototype.processChunk=function(l){if(l){var A=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=A+l.data.length}o.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,r,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataWorker");var A=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(c){A.dataIsReady=!0,A.data=c,A.max=c&&c.length||0,A.type=s.getTypeOf(c),A.isPaused||A._tickAndRepeat()},function(c){A.error(c)})}s.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,A=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,A);break;case"uint8array":l=this.data.subarray(this.index,A);break;case"array":case"nodebuffer":l=this.data.slice(this.index,A)}return this.index=A,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,r,i){function s(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l "+o:o}},r.exports=s},{}],29:[function(t,r,i){var s=t("../utils"),o=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),A=t("../support"),c=t("../external"),u=null;if(A.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(p,d){return new c.Promise(function(g,m){var y=[],w=p._internalType,x=p._outputType,_=p._mimeType;p.on("data",function(C,S){y.push(C),d&&d(S)}).on("error",function(C){y=[],m(C)}).on("end",function(){try{var C=function(S,b,M){switch(S){case"blob":return s.newBlob(s.transformTo("arraybuffer",b),M);case"base64":return l.encode(b);default:return s.transformTo(S,b)}}(x,function(S,b){var M,D=0,$=null,H=0;for(M=0;M"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,r,i){for(var s=t("./utils"),o=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),A=new Array(256),c=0;c<256;c++)A[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;A[254]=A[254]=1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}i.utf8encode=function(h){return o.nodebuffer?a.newBufferFrom(h,"utf-8"):function(p){var d,g,m,y,w,x=p.length,_=0;for(y=0;y>>6:(g<65536?d[w++]=224|g>>>12:(d[w++]=240|g>>>18,d[w++]=128|g>>>12&63),d[w++]=128|g>>>6&63),d[w++]=128|63&g);return d}(h)},i.utf8decode=function(h){return o.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):function(p){var d,g,m,y,w=p.length,x=new Array(2*w);for(d=g=0;d>10&1023,x[g++]=56320|1023&m)}return x.length!==g&&(x.subarray?x=x.subarray(0,g):x.length=g),s.applyFromCharCode(x)}(h=s.transformTo(o.uint8array?"uint8array":"array",h))},s.inherits(u,l),u.prototype.processChunk=function(h){var p=s.transformTo(o.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var d=p;(p=new Uint8Array(d.length+this.leftOver.length)).set(this.leftOver,0),p.set(d,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var g=function(y,w){var x;for((w=w||y.length)>y.length&&(w=y.length),x=w-1;0<=x&&(192&y[x])==128;)x--;return x<0||x===0?w:x+A[y[x]]>w?x:w}(p),m=p;g!==p.length&&(o.uint8array?(m=p.subarray(0,g),this.leftOver=p.subarray(g,p.length)):(m=p.slice(0,g),this.leftOver=p.slice(g,p.length))),this.push({data:i.utf8decode(m),meta:h.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=u,s.inherits(f,l),f.prototype.processChunk=function(h){this.push({data:i.utf8encode(h.data),meta:h.meta})},i.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,r,i){var s=t("./support"),o=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function A(d){return d}function c(d,g){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var p,d,g,m=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4>>6:(h<65536?f[g++]=224|h>>>12:(f[g++]=240|h>>>18,f[g++]=128|h>>>12&63),f[g++]=128|h>>>6&63),f[g++]=128|63&h);return f},i.buf2binstring=function(u){return c(u,u.length)},i.binstring2buf=function(u){for(var f=new s.Buf8(u.length),h=0,p=f.length;h>10&1023,y[p++]=56320|1023&d)}return c(y,p)},i.utf8border=function(u,f){var h;for((f=f||u.length)>u.length&&(f=u.length),h=f-1;0<=h&&(192&u[h])==128;)h--;return h<0||h===0?f:h+l[u[h]]>f?h:f}},{"./common":41}],43:[function(t,r,i){r.exports=function(s,o,a,l){for(var A=65535&s|0,c=s>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3>>1:o>>>1;a[l]=o}return a}();r.exports=function(o,a,l,A){var c=s,u=A+l;o^=-1;for(var f=A;f>>8^c[255&(o^a[f])];return-1^o}},{}],46:[function(t,r,i){var s,o=t("../utils/common"),a=t("./trees"),l=t("./adler32"),A=t("./crc32"),c=t("./messages"),u=0,f=4,h=0,p=-2,d=-1,g=4,m=2,y=8,w=9,x=286,_=30,C=19,S=2*x+1,b=15,M=3,D=258,$=D+M+1,H=42,I=113,v=1,E=2,U=3,P=4;function L(Q,de){return Q.msg=c[de],de}function z(Q){return(Q<<1)-(4Q.avail_out&&(Ae=Q.avail_out),Ae!==0&&(o.arraySet(Q.output,de.pending_buf,de.pending_out,Ae,Q.next_out),Q.next_out+=Ae,de.pending_out+=Ae,Q.total_out+=Ae,Q.avail_out-=Ae,de.pending-=Ae,de.pending===0&&(de.pending_out=0))}function B(Q,de){a._tr_flush_block(Q,0<=Q.block_start?Q.block_start:-1,Q.strstart-Q.block_start,de),Q.block_start=Q.strstart,O(Q.strm)}function W(Q,de){Q.pending_buf[Q.pending++]=de}function ee(Q,de){Q.pending_buf[Q.pending++]=de>>>8&255,Q.pending_buf[Q.pending++]=255&de}function F(Q,de){var Ae,q,J=Q.max_chain_length,ce=Q.strstart,xe=Q.prev_length,be=Q.nice_match,N=Q.strstart>Q.w_size-$?Q.strstart-(Q.w_size-$):0,j=Q.window,se=Q.w_mask,he=Q.prev,me=Q.strstart+D,G=j[ce+xe-1],R=j[ce+xe];Q.prev_length>=Q.good_match&&(J>>=2),be>Q.lookahead&&(be=Q.lookahead);do if(j[(Ae=de)+xe]===R&&j[Ae+xe-1]===G&&j[Ae]===j[ce]&&j[++Ae]===j[ce+1]){ce+=2,Ae++;do;while(j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&ceN&&--J!=0);return xe<=Q.lookahead?xe:Q.lookahead}function X(Q){var de,Ae,q,J,ce,xe,be,N,j,se,he=Q.w_size;do{if(J=Q.window_size-Q.lookahead-Q.strstart,Q.strstart>=he+(he-$)){for(o.arraySet(Q.window,Q.window,he,he,0),Q.match_start-=he,Q.strstart-=he,Q.block_start-=he,de=Ae=Q.hash_size;q=Q.head[--de],Q.head[de]=he<=q?q-he:0,--Ae;);for(de=Ae=he;q=Q.prev[--de],Q.prev[de]=he<=q?q-he:0,--Ae;);J+=he}if(Q.strm.avail_in===0)break;if(xe=Q.strm,be=Q.window,N=Q.strstart+Q.lookahead,j=J,se=void 0,se=xe.avail_in,j=M)for(ce=Q.strstart-Q.insert,Q.ins_h=Q.window[ce],Q.ins_h=(Q.ins_h<=M&&(Q.ins_h=(Q.ins_h<=M)if(q=a._tr_tally(Q,Q.strstart-Q.match_start,Q.match_length-M),Q.lookahead-=Q.match_length,Q.match_length<=Q.max_lazy_match&&Q.lookahead>=M){for(Q.match_length--;Q.strstart++,Q.ins_h=(Q.ins_h<=M&&(Q.ins_h=(Q.ins_h<=M&&Q.match_length<=Q.prev_length){for(J=Q.strstart+Q.lookahead-M,q=a._tr_tally(Q,Q.strstart-1-Q.prev_match,Q.prev_length-M),Q.lookahead-=Q.prev_length-1,Q.prev_length-=2;++Q.strstart<=J&&(Q.ins_h=(Q.ins_h<Q.pending_buf_size-5&&(Ae=Q.pending_buf_size-5);;){if(Q.lookahead<=1){if(X(Q),Q.lookahead===0&&de===u)return v;if(Q.lookahead===0)break}Q.strstart+=Q.lookahead,Q.lookahead=0;var q=Q.block_start+Ae;if((Q.strstart===0||Q.strstart>=q)&&(Q.lookahead=Q.strstart-q,Q.strstart=q,B(Q,!1),Q.strm.avail_out===0)||Q.strstart-Q.block_start>=Q.w_size-$&&(B(Q,!1),Q.strm.avail_out===0))return v}return Q.insert=0,de===f?(B(Q,!0),Q.strm.avail_out===0?U:P):(Q.strstart>Q.block_start&&(B(Q,!1),Q.strm.avail_out),v)}),new oe(4,4,8,4,ue),new oe(4,5,16,8,ue),new oe(4,6,32,32,ue),new oe(4,4,16,16,le),new oe(8,16,32,32,le),new oe(8,16,128,128,le),new oe(8,32,128,256,le),new oe(32,128,258,1024,le),new oe(32,258,258,4096,le)],i.deflateInit=function(Q,de){return Re(Q,de,y,15,8,0)},i.deflateInit2=Re,i.deflateReset=_e,i.deflateResetKeep=pe,i.deflateSetHeader=function(Q,de){return Q&&Q.state?Q.state.wrap!==2?p:(Q.state.gzhead=de,h):p},i.deflate=function(Q,de){var Ae,q,J,ce;if(!Q||!Q.state||5>8&255),W(q,q.gzhead.time>>16&255),W(q,q.gzhead.time>>24&255),W(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),W(q,255&q.gzhead.os),q.gzhead.extra&&q.gzhead.extra.length&&(W(q,255&q.gzhead.extra.length),W(q,q.gzhead.extra.length>>8&255)),q.gzhead.hcrc&&(Q.adler=A(Q.adler,q.pending_buf,q.pending,0)),q.gzindex=0,q.status=69):(W(q,0),W(q,0),W(q,0),W(q,0),W(q,0),W(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),W(q,3),q.status=I);else{var xe=y+(q.w_bits-8<<4)<<8;xe|=(2<=q.strategy||q.level<2?0:q.level<6?1:q.level===6?2:3)<<6,q.strstart!==0&&(xe|=32),xe+=31-xe%31,q.status=I,ee(q,xe),q.strstart!==0&&(ee(q,Q.adler>>>16),ee(q,65535&Q.adler)),Q.adler=1}if(q.status===69)if(q.gzhead.extra){for(J=q.pending;q.gzindex<(65535&q.gzhead.extra.length)&&(q.pending!==q.pending_buf_size||(q.gzhead.hcrc&&q.pending>J&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),O(Q),J=q.pending,q.pending!==q.pending_buf_size));)W(q,255&q.gzhead.extra[q.gzindex]),q.gzindex++;q.gzhead.hcrc&&q.pending>J&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),q.gzindex===q.gzhead.extra.length&&(q.gzindex=0,q.status=73)}else q.status=73;if(q.status===73)if(q.gzhead.name){J=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>J&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),O(Q),J=q.pending,q.pending===q.pending_buf_size)){ce=1;break}ce=q.gzindexJ&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),ce===0&&(q.gzindex=0,q.status=91)}else q.status=91;if(q.status===91)if(q.gzhead.comment){J=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>J&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),O(Q),J=q.pending,q.pending===q.pending_buf_size)){ce=1;break}ce=q.gzindexJ&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),ce===0&&(q.status=103)}else q.status=103;if(q.status===103&&(q.gzhead.hcrc?(q.pending+2>q.pending_buf_size&&O(Q),q.pending+2<=q.pending_buf_size&&(W(q,255&Q.adler),W(q,Q.adler>>8&255),Q.adler=0,q.status=I)):q.status=I),q.pending!==0){if(O(Q),Q.avail_out===0)return q.last_flush=-1,h}else if(Q.avail_in===0&&z(de)<=z(Ae)&&de!==f)return L(Q,-5);if(q.status===666&&Q.avail_in!==0)return L(Q,-5);if(Q.avail_in!==0||q.lookahead!==0||de!==u&&q.status!==666){var be=q.strategy===2?function(N,j){for(var se;;){if(N.lookahead===0&&(X(N),N.lookahead===0)){if(j===u)return v;break}if(N.match_length=0,se=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++,se&&(B(N,!1),N.strm.avail_out===0))return v}return N.insert=0,j===f?(B(N,!0),N.strm.avail_out===0?U:P):N.last_lit&&(B(N,!1),N.strm.avail_out===0)?v:E}(q,de):q.strategy===3?function(N,j){for(var se,he,me,G,R=N.window;;){if(N.lookahead<=D){if(X(N),N.lookahead<=D&&j===u)return v;if(N.lookahead===0)break}if(N.match_length=0,N.lookahead>=M&&0N.lookahead&&(N.match_length=N.lookahead)}if(N.match_length>=M?(se=a._tr_tally(N,1,N.match_length-M),N.lookahead-=N.match_length,N.strstart+=N.match_length,N.match_length=0):(se=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++),se&&(B(N,!1),N.strm.avail_out===0))return v}return N.insert=0,j===f?(B(N,!0),N.strm.avail_out===0?U:P):N.last_lit&&(B(N,!1),N.strm.avail_out===0)?v:E}(q,de):s[q.level].func(q,de);if(be!==U&&be!==P||(q.status=666),be===v||be===U)return Q.avail_out===0&&(q.last_flush=-1),h;if(be===E&&(de===1?a._tr_align(q):de!==5&&(a._tr_stored_block(q,0,0,!1),de===3&&(K(q.head),q.lookahead===0&&(q.strstart=0,q.block_start=0,q.insert=0))),O(Q),Q.avail_out===0))return q.last_flush=-1,h}return de!==f?h:q.wrap<=0?1:(q.wrap===2?(W(q,255&Q.adler),W(q,Q.adler>>8&255),W(q,Q.adler>>16&255),W(q,Q.adler>>24&255),W(q,255&Q.total_in),W(q,Q.total_in>>8&255),W(q,Q.total_in>>16&255),W(q,Q.total_in>>24&255)):(ee(q,Q.adler>>>16),ee(q,65535&Q.adler)),O(Q),0=Ae.w_size&&(ce===0&&(K(Ae.head),Ae.strstart=0,Ae.block_start=0,Ae.insert=0),j=new o.Buf8(Ae.w_size),o.arraySet(j,de,se-Ae.w_size,Ae.w_size,0),de=j,se=Ae.w_size),xe=Q.avail_in,be=Q.next_in,N=Q.input,Q.avail_in=se,Q.next_in=0,Q.input=de,X(Ae);Ae.lookahead>=M;){for(q=Ae.strstart,J=Ae.lookahead-(M-1);Ae.ins_h=(Ae.ins_h<>>=M=b>>>24,w-=M,(M=b>>>16&255)===0)E[c++]=65535&b;else{if(!(16&M)){if(!(64&M)){b=x[(65535&b)+(y&(1<>>=M,w-=M),w<15&&(y+=v[l++]<>>=M=b>>>24,w-=M,!(16&(M=b>>>16&255))){if(!(64&M)){b=_[(65535&b)+(y&(1<>>=M,w-=M,(M=c-u)<$){if(d<(M=$-M)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(I=m,(H=0)===g){if(H+=p-M,M>3,y&=(1<<(w-=D<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l>>24&255)+(H>>>8&65280)+((65280&H)<<8)+((255&H)<<24)}function y(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(H){var I;return H&&H.state?(I=H.state,H.total_in=H.total_out=I.total=0,H.msg="",I.wrap&&(H.adler=1&I.wrap),I.mode=p,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new s.Buf32(d),I.distcode=I.distdyn=new s.Buf32(g),I.sane=1,I.back=-1,f):h}function x(H){var I;return H&&H.state?((I=H.state).wsize=0,I.whave=0,I.wnext=0,w(H)):h}function _(H,I){var v,E;return H&&H.state?(E=H.state,I<0?(v=0,I=-I):(v=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15=P.wsize?(s.arraySet(P.window,I,v-P.wsize,P.wsize,0),P.wnext=0,P.whave=P.wsize):(E<(U=P.wsize-P.wnext)&&(U=E),s.arraySet(P.window,I,v-E,U,P.wnext),(E-=U)?(s.arraySet(P.window,I,v-E,E,0),P.wnext=E,P.whave=P.wsize):(P.wnext+=U,P.wnext===P.wsize&&(P.wnext=0),P.whave>>8&255,v.check=a(v.check,ce,2,0),B=O=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&O)<<8)+(O>>8))%31){H.msg="incorrect header check",v.mode=30;break}if((15&O)!=8){H.msg="unknown compression method",v.mode=30;break}if(B-=4,Q=8+(15&(O>>>=4)),v.wbits===0)v.wbits=Q;else if(Q>v.wbits){H.msg="invalid window size",v.mode=30;break}v.dmax=1<>8&1),512&v.flags&&(ce[0]=255&O,ce[1]=O>>>8&255,v.check=a(v.check,ce,2,0)),B=O=0,v.mode=3;case 3:for(;B<32;){if(z===0)break e;z--,O+=E[P++]<>>8&255,ce[2]=O>>>16&255,ce[3]=O>>>24&255,v.check=a(v.check,ce,4,0)),B=O=0,v.mode=4;case 4:for(;B<16;){if(z===0)break e;z--,O+=E[P++]<>8),512&v.flags&&(ce[0]=255&O,ce[1]=O>>>8&255,v.check=a(v.check,ce,2,0)),B=O=0,v.mode=5;case 5:if(1024&v.flags){for(;B<16;){if(z===0)break e;z--,O+=E[P++]<>>8&255,v.check=a(v.check,ce,2,0)),B=O=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(z<(F=v.length)&&(F=z),F&&(v.head&&(Q=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),s.arraySet(v.head.extra,E,P,F,Q)),512&v.flags&&(v.check=a(v.check,E,F,P)),z-=F,P+=F,v.length-=F),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(z===0)break e;for(F=0;Q=E[P+F++],v.head&&Q&&v.length<65536&&(v.head.name+=String.fromCharCode(Q)),Q&&F>9&1,v.head.done=!0),H.adler=v.check=0,v.mode=12;break;case 10:for(;B<32;){if(z===0)break e;z--,O+=E[P++]<>>=7&B,B-=7&B,v.mode=27;break}for(;B<3;){if(z===0)break e;z--,O+=E[P++]<>>=1)){case 0:v.mode=14;break;case 1:if(D(v),v.mode=20,I!==6)break;O>>>=2,B-=2;break e;case 2:v.mode=17;break;case 3:H.msg="invalid block type",v.mode=30}O>>>=2,B-=2;break;case 14:for(O>>>=7&B,B-=7&B;B<32;){if(z===0)break e;z--,O+=E[P++]<>>16^65535)){H.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&O,B=O=0,v.mode=15,I===6)break e;case 15:v.mode=16;case 16:if(F=v.length){if(z>>=5,B-=5,v.ndist=1+(31&O),O>>>=5,B-=5,v.ncode=4+(15&O),O>>>=4,B-=4,286>>=3,B-=3}for(;v.have<19;)v.lens[xe[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,Ae={bits:v.lenbits},de=A(0,v.lens,0,19,v.lencode,0,v.work,Ae),v.lenbits=Ae.bits,de){H.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have>>16&255,re=65535&J,!((le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>>=le,B-=le,v.lens[v.have++]=re;else{if(re===16){for(q=le+2;B>>=le,B-=le,v.have===0){H.msg="invalid bit length repeat",v.mode=30;break}Q=v.lens[v.have-1],F=3+(3&O),O>>>=2,B-=2}else if(re===17){for(q=le+3;B>>=le)),O>>>=3,B-=3}else{for(q=le+7;B>>=le)),O>>>=7,B-=7}if(v.have+F>v.nlen+v.ndist){H.msg="invalid bit length repeat",v.mode=30;break}for(;F--;)v.lens[v.have++]=Q}}if(v.mode===30)break;if(v.lens[256]===0){H.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,Ae={bits:v.lenbits},de=A(c,v.lens,0,v.nlen,v.lencode,0,v.work,Ae),v.lenbits=Ae.bits,de){H.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,Ae={bits:v.distbits},de=A(u,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,Ae),v.distbits=Ae.bits,de){H.msg="invalid distances set",v.mode=30;break}if(v.mode=20,I===6)break e;case 20:v.mode=21;case 21:if(6<=z&&258<=K){H.next_out=L,H.avail_out=K,H.next_in=P,H.avail_in=z,v.hold=O,v.bits=B,l(H,ee),L=H.next_out,U=H.output,K=H.avail_out,P=H.next_in,E=H.input,z=H.avail_in,O=v.hold,B=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;oe=(J=v.lencode[O&(1<>>16&255,re=65535&J,!((le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>pe)])>>>16&255,re=65535&J,!(pe+(le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>>=pe,B-=pe,v.back+=pe}if(O>>>=le,B-=le,v.back+=le,v.length=re,oe===0){v.mode=26;break}if(32&oe){v.back=-1,v.mode=12;break}if(64&oe){H.msg="invalid literal/length code",v.mode=30;break}v.extra=15&oe,v.mode=22;case 22:if(v.extra){for(q=v.extra;B>>=v.extra,B-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;oe=(J=v.distcode[O&(1<>>16&255,re=65535&J,!((le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>pe)])>>>16&255,re=65535&J,!(pe+(le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>>=pe,B-=pe,v.back+=pe}if(O>>>=le,B-=le,v.back+=le,64&oe){H.msg="invalid distance code",v.mode=30;break}v.offset=re,v.extra=15&oe,v.mode=24;case 24:if(v.extra){for(q=v.extra;B>>=v.extra,B-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){H.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(K===0)break e;if(F=ee-K,v.offset>F){if((F=v.offset-F)>v.whave&&v.sane){H.msg="invalid distance too far back",v.mode=30;break}X=F>v.wnext?(F-=v.wnext,v.wsize-F):v.wnext-F,F>v.length&&(F=v.length),ue=v.window}else ue=U,X=L-v.offset,F=v.length;for(KS?(M=X[ue+g[I]],B[W+g[I]]):(M=96,0),y=1<>L)+(w-=y)]=b<<24|M<<16|D|0,w!==0;);for(y=1<>=1;if(y!==0?(O&=y-1,O+=y):O=0,I++,--ee[H]==0){if(H===E)break;H=u[f+g[I]]}if(U>>7)]}function W(J,ce){J.pending_buf[J.pending++]=255&ce,J.pending_buf[J.pending++]=ce>>>8&255}function ee(J,ce,xe){J.bi_valid>m-xe?(J.bi_buf|=ce<>m-J.bi_valid,J.bi_valid+=xe-m):(J.bi_buf|=ce<>>=1,xe<<=1,0<--ce;);return xe>>>1}function ue(J,ce,xe){var be,N,j=new Array(g+1),se=0;for(be=1;be<=g;be++)j[be]=se=se+xe[be-1]<<1;for(N=0;N<=ce;N++){var he=J[2*N+1];he!==0&&(J[2*N]=X(j[he]++,he))}}function le(J){var ce;for(ce=0;ce>1;1<=xe;xe--)pe(J,j,xe);for(N=me;xe=J.heap[1],J.heap[1]=J.heap[J.heap_len--],pe(J,j,1),be=J.heap[1],J.heap[--J.heap_max]=xe,J.heap[--J.heap_max]=be,j[2*N]=j[2*xe]+j[2*be],J.depth[N]=(J.depth[xe]>=J.depth[be]?J.depth[xe]:J.depth[be])+1,j[2*xe+1]=j[2*be+1]=N,J.heap[1]=N++,pe(J,j,1),2<=J.heap_len;);J.heap[--J.heap_max]=J.heap[1],function(R,T){var V,te,ae,ie,Te,Me,Le=T.dyn_tree,ke=T.max_code,De=T.stat_desc.static_tree,fe=T.stat_desc.has_stree,Ce=T.stat_desc.extra_bits,Se=T.stat_desc.extra_base,Fe=T.stat_desc.max_length,We=0;for(ie=0;ie<=g;ie++)R.bl_count[ie]=0;for(Le[2*R.heap[R.heap_max]+1]=0,V=R.heap_max+1;V>=7;N>>=1)if(1&G&&he.dyn_ltree[2*me]!==0)return o;if(he.dyn_ltree[18]!==0||he.dyn_ltree[20]!==0||he.dyn_ltree[26]!==0)return a;for(me=32;me>>3,(j=J.static_len+3+7>>>3)<=N&&(N=j)):N=j=xe+5,xe+4<=N&&ce!==-1?q(J,ce,xe,be):J.strategy===4||j===N?(ee(J,2+(be?1:0),3),_e(J,$,H)):(ee(J,4+(be?1:0),3),function(he,me,G,R){var T;for(ee(he,me-257,5),ee(he,G-1,5),ee(he,R-4,4),T=0;T>>8&255,J.pending_buf[J.d_buf+2*J.last_lit+1]=255&ce,J.pending_buf[J.l_buf+J.last_lit]=255&xe,J.last_lit++,ce===0?J.dyn_ltree[2*xe]++:(J.matches++,ce--,J.dyn_ltree[2*(v[xe]+u+1)]++,J.dyn_dtree[2*B(ce)]++),J.last_lit===J.lit_bufsize-1},i._tr_align=function(J){ee(J,2,3),F(J,w,$),function(ce){ce.bi_valid===16?(W(ce,ce.bi_buf),ce.bi_buf=0,ce.bi_valid=0):8<=ce.bi_valid&&(ce.pending_buf[ce.pending++]=255&ce.bi_buf,ce.bi_buf>>=8,ce.bi_valid-=8)}(J)}},{"../utils/common":41}],53:[function(t,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,r,i){(function(s){(function(o,a){if(!o.setImmediate){var l,A,c,u,f=1,h={},p=!1,d=o.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(o);g=g&&g.setTimeout?g:o,l={}.toString.call(o.process)==="[object process]"?function(x){process.nextTick(function(){y(x)})}:function(){if(o.postMessage&&!o.importScripts){var x=!0,_=o.onmessage;return o.onmessage=function(){x=!1},o.postMessage("","*"),o.onmessage=_,x}}()?(u="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",w,!1):o.attachEvent("onmessage",w),function(x){o.postMessage(u+x,"*")}):o.MessageChannel?((c=new MessageChannel).port1.onmessage=function(x){y(x.data)},function(x){c.port2.postMessage(x)}):d&&"onreadystatechange"in d.createElement("script")?(A=d.documentElement,function(x){var _=d.createElement("script");_.onreadystatechange=function(){y(x),_.onreadystatechange=null,A.removeChild(_),_=null},A.appendChild(_)}):function(x){setTimeout(y,0,x)},g.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var _=new Array(arguments.length-1),C=0;C<_.length;C++)_[C]=arguments[C+1];var S={callback:x,args:_};return h[f]=S,l(f),f++},g.clearImmediate=m}function m(x){delete h[x]}function y(x){if(p)setTimeout(y,0,x);else{var _=h[x];if(_){p=!0;try{(function(C){var S=C.callback,b=C.args;switch(b.length){case 0:S();break;case 1:S(b[0]);break;case 2:S(b[0],b[1]);break;case 3:S(b[0],b[1],b[2]);break;default:S.apply(a,b)}})(_)}finally{m(x),p=!1}}}}function w(x){x.source===o&&typeof x.data=="string"&&x.data.indexOf(u)===0&&y(+x.data.slice(u.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof ta<"u"?ta:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(P5);var fhe=P5.exports;const hhe=bl(fhe);class ad{constructor(){this.zipContainer={}}addData(e,t,r,i=""){i==""&&(i="_"),this.zipContainer[i]==null&&(this.zipContainer[i]=[]),this.zipContainer[i].push({data:e,name:t,extension:r})}saveZip(e,t=!0){const r=this.zipContainer,i=new hhe;for(const s in r)if(s=="_")r[s].forEach((o,a)=>{i.file(o.name+"."+o.extension,o.data,{base64:!0})});else{const o=i.folder(s);r[s].forEach((a,l)=>{const A=a.extension!="txt";o.file(a.name+"."+a.extension,a.data,{base64:A})})}i.generateAsync({type:"blob"}).then(s=>{this._saveZipFile(s,e+".zip")}),t&&(this.zipContainer={})}_saveZipFile(e,t){const r=new Blob([e],{type:"application/zip"});if(typeof window.navigator.msSaveBlob<"u")window.navigator.msSaveBlob(r,t);else{const i=document.createElement("a");typeof i.download=="string"?(document.body.appendChild(i),i.download=t,i.href=URL.createObjectURL(r),i.click(),document.body.removeChild(i)):window.open(e,"_blank").document.write(""+t+"")}}}new Z;class dhe{constructor(e){this.characterManager=e,this.screenshotManager=e.screenshotManager,this.blinkManager=e.blinkManager,this.animationManager=this.characterManager.animationManager,this.temptime=0}async createLoraData(e,t=null,r="",i){const s=e.manifest,o=e.name?"loraData/"+e.name:"loraData",a=await this._fetchManifest(s),{assetsLocation:l="",animationsDirectory:A="",backgroundGrayscale:c=1,topFrameOffsetPixels:u=64,bottomFrameOffsetPixels:f=64,backgroundDescription:h="",width:p=512,height:d=512,dataCollection:g}=a,m=l+A+"/";this.screenshotManager.setBackground([c,c,c]),this.blinkManager.enableScreenshot(),await this.screenshotManager.calculateBoneOffsets(.2);let y=0;const w=this;if(Array.isArray(g)){const x=t??new ad;await(async()=>{if(Array.isArray(g))for(let C=0;C{const K=[];return ct(U).forEach(B=>{K.push({id:B})}),K},L=U==null?y.characterManager.getTraits(S):P();if(L==null){console.log("SKipping Thumbnail Generation for trait group "+S+", its not present in the character manifest.");continue}const z=wT(b);E?y.screenshotManager.setCameraFrameWithName(E,z):y.screenshotManager.frameShot(M,$,z,D,H);for(let K=0;K{const[e,t]=ye.useState(null),[r,i]=ye.useState(null),[s,o]=ye.useState(null),[a,l]=ye.useState(null),[A,c]=ye.useState(null),[u,f]=ye.useState(null),[h,p]=ye.useState(null),[d,g]=ye.useState(null),[m,y]=ye.useState(null),[w,x]=ye.useState(null),[_,C]=ye.useState(null),[S,b]=ye.useState(!1);let M=!1,[D,$]=ye.useState(!1);ye.useEffect(()=>{if(M||D)return;$(!0),M=!0;const{scene:E,camera:U,controls:P,characterManager:L,sceneElements:z}=uhe("editor-scene");y(U),g(E),t(L),c(z),f(L.animationManager),p(L.lookAtManager),x(P),i(new dhe(L)),o(new phe(L)),l(new mhe(L))},[]);const H=E=>{E==null&&(E=!S),b(E),d.traverse(U=>{U.isMesh&&U.setDebugMode&&U.setDebugMode(E)})};ye.useEffect(()=>{if(_!=null&&_.defaultAnimations){const E=_.defaultAnimations.map(U=>U.location);u.storeDefaultAnimationPaths(E,"")}},[_]);const I=E=>{E?d.add(A):d.remove(A)},v=E=>{w&&(tC.to(w.target,{x:E.targetX??0,y:E.targetY??0,z:E.targetZ??0,duration:1}),tC.fromTo(w,{maxDistance:w.getDistance(),minDistance:w.getDistance(),minPolarAngle:w.getPolarAngle(),maxPolarAngle:w.getPolarAngle(),minAzimuthAngle:w.getAzimuthalAngle(),maxAzimuthAngle:w.getAzimuthalAngle()},{maxDistance:E.distance,minDistance:E.distance,minPolarAngle:Math.PI/2-.11,maxPolarAngle:Math.PI/2-.11,minAzimuthAngle:-.78,maxAzimuthAngle:-.78,duration:1}).then(()=>{w.minPolarAngle=0,w.maxPolarAngle=3.1415,w.minDistance=.5,w.maxDistance=10,w.minAzimuthAngle=1/0,w.maxAzimuthAngle=1/0}))};return k.jsx(or.Provider,{value:{manifest:_,setManifest:C,scene:d,characterManager:e,loraDataGenerator:r,spriteAtlasGenerator:s,thumbnailsGenerator:a,showEnvironmentModels:I,debugMode:S,toggleDebugMode:H,animationManager:u,lookAtManager:h,camera:m,moveCamera:v,controls:w,sceneElements:A},children:n.children})},vhe={NORMAL:"NORMAL",AR:"AR",AR_FRONT:"AR_FRONT",VR:"VR"},dt={LANDING:"LANDING",CREATE:"CREATE",CLAIM:"CLAIM",LOAD:"LOAD",APPEARANCE:"APPEARANCE",BATCHDOWNLOAD:"BATCHDOWNLOAD",SAVE:"SAVE",MINT:"MINT",OPTIMIZER:"OPTIMIZER",BATCHMANIFEST:"BATCHMANIFEST",WALLET:"WALLET"},Ui=Y.createContext(),yhe=n=>{const[e,t]=Y.useState(vhe.NORMAL),[r,i]=Y.useState(dt.LANDING),[s,o]=Y.useState(!1),[a,l]=Y.useState(!1);return k.jsx(Ui.Provider,{value:{viewMode:r,setViewMode:i,isLoading:s,setIsLoading:o,mouseIsOverUI:a,setMouseIsOverUI:l,currentCameraMode:e,setCurrentCameraMode:t},children:n.children})},whe="modulepreload",xhe=function(n){return"/CharacterStudio/"+n},q3={},_he=function(e,t,r){if(!t||t.length===0)return e();const i=document.getElementsByTagName("link");return Promise.all(t.map(s=>{if(s=xhe(s),s in q3)return;q3[s]=!0;const o=s.endsWith(".css"),a=o?'[rel="stylesheet"]':"";if(!!r)for(let c=i.length-1;c>=0;c--){const u=i[c];if(u.href===s&&(!o||u.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${a}`))return;const A=document.createElement("link");if(A.rel=o?"stylesheet":whe,o||(A.as="script",A.crossOrigin=""),A.href=s,document.head.appendChild(A),o)return new Promise((c,u)=>{A.addEventListener("load",c),A.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${s}`)))})})).then(()=>e()).catch(s=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s})};function zw(){return zw=Object.assign||function(n){for(var e=1;e=0)&&(t[i]=n[i]);return t}function Bhe(n){ye.useEffect(n,[])}function Ehe(n,e){e===void 0&&(e={});var t=e,r=t.volume,i=r===void 0?1:r,s=t.playbackRate,o=s===void 0?1:s,a=t.soundEnabled,l=a===void 0?!0:a,A=t.interrupt,c=A===void 0?!1:A,u=t.onload,f=bhe(t,["id","volume","playbackRate","soundEnabled","interrupt","onload"]),h=Y.useRef(null),p=Y.useRef(!1),d=Y.useState(null),g=d[0],m=d[1],y=Y.useState(null),w=y[0],x=y[1],_=function(){typeof u=="function"&&u.call(this),p.current&&m(this.duration()*1e3),x(this)};Bhe(function(){return _he(()=>import("./howler-1d21b928.js").then(D=>D.h),[]).then(function(D){if(!p.current){var $;h.current=($=D.Howl)!==null&&$!==void 0?$:D.default.Howl,p.current=!0,new h.current(zw({src:Array.isArray(n)?n:[n],volume:i,rate:o,onload:_},f))}}),function(){p.current=!1}}),Y.useEffect(function(){h.current&&w&&x(new h.current(zw({src:Array.isArray(n)?n:[n],volume:i,onload:_},f)))},[JSON.stringify(n)]),Y.useEffect(function(){w&&(w.volume(i),w.rate(o))},[i,o]);var C=Y.useCallback(function(D){typeof D>"u"&&(D={}),!(!w||!l&&!D.forceSoundEnabled)&&(c&&w.stop(),D.playbackRate&&w.rate(D.playbackRate),w.play(D.id))},[w,l,c]),S=Y.useCallback(function(D){w&&w.stop(D)},[w]),b=Y.useCallback(function(D){w&&w.pause(D)},[w]),M=[C,{sound:w,stop:S,pause:b,duration:g}];return M}const Che=[{name:"background/cc_bgm.wav",offset:0,duration:123458.58333333334},{name:"background/cc_bgm_balanced.wav",offset:123458.58333333334,duration:123458.60416666666},{name:"effect/character-load.wav",offset:246917.1875,duration:3030},{name:"effect/class-select.wav",offset:249947.1875,duration:2780},{name:"effect/switchingItem.wav",offset:252727.1875,duration:623.75},{name:"ui/back-next-button.wav",offset:253350.9375,duration:155.02083333333334},{name:"ui/class-mouse-over.wav",offset:253505.95833333334,duration:217.52083333333334},{name:"ui/class_click.wav",offset:253723.4791666667,duration:3123.75},{name:"ui/class_pass.wav",offset:256847.2291666667,duration:155},{name:"ui/option_click.wav",offset:257002.2291666667,duration:155.02083333333334},{name:"ui/randomize-button.wav",offset:257157.25000000003,duration:342.5208333333333},{name:"ui/section_click.wav",offset:257499.77083333337,duration:155}],She="/CharacterStudio/assets/sounds-3322d50e.mp3",Ys=ye.createContext(),Mhe=n=>{const e=i=>Che.find(s=>i.test(s.name)),[t]=Ehe(She,{sprite:{switchItem:[e(/switchingItem/).offset,e(/switchingItem/).duration],classSelect:[e(/class-select/).offset,e(/class-select/).duration],characterLoad:[e(/character-load/).offset,e(/character-load/).duration],randomizeButton:[e(/randomize-button/).offset,e(/randomize-button/).duration],classMouseOver:[e(/class-mouse-over/).offset,e(/class-mouse-over/).duration],backNextButton:[e(/back-next-button/).offset,e(/back-next-button/).duration]}}),r=(i,s=0)=>{s===0?t({id:i}):setTimeout(()=>{t({id:i})},s)};return k.jsx(Ys.Provider,{value:{playSound:r},children:n.children})};function ks(n){"@babel/helpers - typeof";return ks=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ks(n)}function Xs(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function The(n,e){if(ks(n)!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(ks(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function D5(n){var e=The(n,"string");return ks(e)=="symbol"?e:e+""}function eP(n,e){for(var t=0;tn.length)&&(e=n.length);for(var t=0,r=new Array(e);t=this.index;l--)A=(A<<8)+this.byteAt(l);return this.index+=a,A},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=o},{"../utils":32}],19:[function(t,r,i){var s=t("./Uint8ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,r,i){var s=t("./DataReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./DataReader":18}],21:[function(t,r,i){var s=t("./ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(t,r,i){var s=t("../utils"),o=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),A=t("./NodeBufferReader"),c=t("./Uint8ArrayReader");r.exports=function(u){var f=s.getTypeOf(u);return s.checkSupport(f),f!=="string"||o.uint8array?f==="nodebuffer"?new A(u):o.uint8array?new c(s.transformTo("uint8array",u)):new a(s.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,r,i){var s=t("./GenericWorker"),o=t("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,r,i){var s=t("./GenericWorker"),o=t("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,r,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,o),a.prototype.processChunk=function(l){if(l){var A=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=A+l.data.length}o.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,r,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataWorker");var A=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(c){A.dataIsReady=!0,A.data=c,A.max=c&&c.length||0,A.type=s.getTypeOf(c),A.isPaused||A._tickAndRepeat()},function(c){A.error(c)})}s.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,A=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,A);break;case"uint8array":l=this.data.subarray(this.index,A);break;case"array":case"nodebuffer":l=this.data.slice(this.index,A)}return this.index=A,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,r,i){function s(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l "+o:o}},r.exports=s},{}],29:[function(t,r,i){var s=t("../utils"),o=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),A=t("../support"),c=t("../external"),u=null;if(A.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(p,d){return new c.Promise(function(g,m){var y=[],w=p._internalType,x=p._outputType,_=p._mimeType;p.on("data",function(C,S){y.push(C),d&&d(S)}).on("error",function(C){y=[],m(C)}).on("end",function(){try{var C=function(S,b,M){switch(S){case"blob":return s.newBlob(s.transformTo("arraybuffer",b),M);case"base64":return l.encode(b);default:return s.transformTo(S,b)}}(x,function(S,b){var M,D=0,$=null,H=0;for(M=0;M"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,r,i){for(var s=t("./utils"),o=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),A=new Array(256),c=0;c<256;c++)A[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;A[254]=A[254]=1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}i.utf8encode=function(h){return o.nodebuffer?a.newBufferFrom(h,"utf-8"):function(p){var d,g,m,y,w,x=p.length,_=0;for(y=0;y>>6:(g<65536?d[w++]=224|g>>>12:(d[w++]=240|g>>>18,d[w++]=128|g>>>12&63),d[w++]=128|g>>>6&63),d[w++]=128|63&g);return d}(h)},i.utf8decode=function(h){return o.nodebuffer?s.transformTo("nodebuffer",h).toString("utf-8"):function(p){var d,g,m,y,w=p.length,x=new Array(2*w);for(d=g=0;d>10&1023,x[g++]=56320|1023&m)}return x.length!==g&&(x.subarray?x=x.subarray(0,g):x.length=g),s.applyFromCharCode(x)}(h=s.transformTo(o.uint8array?"uint8array":"array",h))},s.inherits(u,l),u.prototype.processChunk=function(h){var p=s.transformTo(o.uint8array?"uint8array":"array",h.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var d=p;(p=new Uint8Array(d.length+this.leftOver.length)).set(this.leftOver,0),p.set(d,this.leftOver.length)}else p=this.leftOver.concat(p);this.leftOver=null}var g=function(y,w){var x;for((w=w||y.length)>y.length&&(w=y.length),x=w-1;0<=x&&(192&y[x])==128;)x--;return x<0||x===0?w:x+A[y[x]]>w?x:w}(p),m=p;g!==p.length&&(o.uint8array?(m=p.subarray(0,g),this.leftOver=p.subarray(g,p.length)):(m=p.slice(0,g),this.leftOver=p.slice(g,p.length))),this.push({data:i.utf8decode(m),meta:h.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=u,s.inherits(f,l),f.prototype.processChunk=function(h){this.push({data:i.utf8encode(h.data),meta:h.meta})},i.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,r,i){var s=t("./support"),o=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function A(d){return d}function c(d,g){for(var m=0;m>8;this.dir=!!(16&this.externalFileAttributes),h==0&&(this.dosPermissions=63&this.externalFileAttributes),h==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var h=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=h.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=h.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=h.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=h.readInt(4))}},readExtraFields:function(h){var p,d,g,m=h.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});h.index+4>>6:(h<65536?f[g++]=224|h>>>12:(f[g++]=240|h>>>18,f[g++]=128|h>>>12&63),f[g++]=128|h>>>6&63),f[g++]=128|63&h);return f},i.buf2binstring=function(u){return c(u,u.length)},i.binstring2buf=function(u){for(var f=new s.Buf8(u.length),h=0,p=f.length;h>10&1023,y[p++]=56320|1023&d)}return c(y,p)},i.utf8border=function(u,f){var h;for((f=f||u.length)>u.length&&(f=u.length),h=f-1;0<=h&&(192&u[h])==128;)h--;return h<0||h===0?f:h+l[u[h]]>f?h:f}},{"./common":41}],43:[function(t,r,i){r.exports=function(s,o,a,l){for(var A=65535&s|0,c=s>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3>>1:o>>>1;a[l]=o}return a}();r.exports=function(o,a,l,A){var c=s,u=A+l;o^=-1;for(var f=A;f>>8^c[255&(o^a[f])];return-1^o}},{}],46:[function(t,r,i){var s,o=t("../utils/common"),a=t("./trees"),l=t("./adler32"),A=t("./crc32"),c=t("./messages"),u=0,f=4,h=0,p=-2,d=-1,g=4,m=2,y=8,w=9,x=286,_=30,C=19,S=2*x+1,b=15,M=3,D=258,$=D+M+1,H=42,I=113,v=1,E=2,U=3,P=4;function L(Q,de){return Q.msg=c[de],de}function z(Q){return(Q<<1)-(4Q.avail_out&&(Ae=Q.avail_out),Ae!==0&&(o.arraySet(Q.output,de.pending_buf,de.pending_out,Ae,Q.next_out),Q.next_out+=Ae,de.pending_out+=Ae,Q.total_out+=Ae,Q.avail_out-=Ae,de.pending-=Ae,de.pending===0&&(de.pending_out=0))}function B(Q,de){a._tr_flush_block(Q,0<=Q.block_start?Q.block_start:-1,Q.strstart-Q.block_start,de),Q.block_start=Q.strstart,O(Q.strm)}function W(Q,de){Q.pending_buf[Q.pending++]=de}function ee(Q,de){Q.pending_buf[Q.pending++]=de>>>8&255,Q.pending_buf[Q.pending++]=255&de}function F(Q,de){var Ae,q,J=Q.max_chain_length,ce=Q.strstart,xe=Q.prev_length,be=Q.nice_match,N=Q.strstart>Q.w_size-$?Q.strstart-(Q.w_size-$):0,j=Q.window,se=Q.w_mask,he=Q.prev,me=Q.strstart+D,G=j[ce+xe-1],R=j[ce+xe];Q.prev_length>=Q.good_match&&(J>>=2),be>Q.lookahead&&(be=Q.lookahead);do if(j[(Ae=de)+xe]===R&&j[Ae+xe-1]===G&&j[Ae]===j[ce]&&j[++Ae]===j[ce+1]){ce+=2,Ae++;do;while(j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&j[++ce]===j[++Ae]&&ceN&&--J!=0);return xe<=Q.lookahead?xe:Q.lookahead}function X(Q){var de,Ae,q,J,ce,xe,be,N,j,se,he=Q.w_size;do{if(J=Q.window_size-Q.lookahead-Q.strstart,Q.strstart>=he+(he-$)){for(o.arraySet(Q.window,Q.window,he,he,0),Q.match_start-=he,Q.strstart-=he,Q.block_start-=he,de=Ae=Q.hash_size;q=Q.head[--de],Q.head[de]=he<=q?q-he:0,--Ae;);for(de=Ae=he;q=Q.prev[--de],Q.prev[de]=he<=q?q-he:0,--Ae;);J+=he}if(Q.strm.avail_in===0)break;if(xe=Q.strm,be=Q.window,N=Q.strstart+Q.lookahead,j=J,se=void 0,se=xe.avail_in,j=M)for(ce=Q.strstart-Q.insert,Q.ins_h=Q.window[ce],Q.ins_h=(Q.ins_h<=M&&(Q.ins_h=(Q.ins_h<=M)if(q=a._tr_tally(Q,Q.strstart-Q.match_start,Q.match_length-M),Q.lookahead-=Q.match_length,Q.match_length<=Q.max_lazy_match&&Q.lookahead>=M){for(Q.match_length--;Q.strstart++,Q.ins_h=(Q.ins_h<=M&&(Q.ins_h=(Q.ins_h<=M&&Q.match_length<=Q.prev_length){for(J=Q.strstart+Q.lookahead-M,q=a._tr_tally(Q,Q.strstart-1-Q.prev_match,Q.prev_length-M),Q.lookahead-=Q.prev_length-1,Q.prev_length-=2;++Q.strstart<=J&&(Q.ins_h=(Q.ins_h<Q.pending_buf_size-5&&(Ae=Q.pending_buf_size-5);;){if(Q.lookahead<=1){if(X(Q),Q.lookahead===0&&de===u)return v;if(Q.lookahead===0)break}Q.strstart+=Q.lookahead,Q.lookahead=0;var q=Q.block_start+Ae;if((Q.strstart===0||Q.strstart>=q)&&(Q.lookahead=Q.strstart-q,Q.strstart=q,B(Q,!1),Q.strm.avail_out===0)||Q.strstart-Q.block_start>=Q.w_size-$&&(B(Q,!1),Q.strm.avail_out===0))return v}return Q.insert=0,de===f?(B(Q,!0),Q.strm.avail_out===0?U:P):(Q.strstart>Q.block_start&&(B(Q,!1),Q.strm.avail_out),v)}),new oe(4,4,8,4,ue),new oe(4,5,16,8,ue),new oe(4,6,32,32,ue),new oe(4,4,16,16,le),new oe(8,16,32,32,le),new oe(8,16,128,128,le),new oe(8,32,128,256,le),new oe(32,128,258,1024,le),new oe(32,258,258,4096,le)],i.deflateInit=function(Q,de){return Re(Q,de,y,15,8,0)},i.deflateInit2=Re,i.deflateReset=_e,i.deflateResetKeep=pe,i.deflateSetHeader=function(Q,de){return Q&&Q.state?Q.state.wrap!==2?p:(Q.state.gzhead=de,h):p},i.deflate=function(Q,de){var Ae,q,J,ce;if(!Q||!Q.state||5>8&255),W(q,q.gzhead.time>>16&255),W(q,q.gzhead.time>>24&255),W(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),W(q,255&q.gzhead.os),q.gzhead.extra&&q.gzhead.extra.length&&(W(q,255&q.gzhead.extra.length),W(q,q.gzhead.extra.length>>8&255)),q.gzhead.hcrc&&(Q.adler=A(Q.adler,q.pending_buf,q.pending,0)),q.gzindex=0,q.status=69):(W(q,0),W(q,0),W(q,0),W(q,0),W(q,0),W(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),W(q,3),q.status=I);else{var xe=y+(q.w_bits-8<<4)<<8;xe|=(2<=q.strategy||q.level<2?0:q.level<6?1:q.level===6?2:3)<<6,q.strstart!==0&&(xe|=32),xe+=31-xe%31,q.status=I,ee(q,xe),q.strstart!==0&&(ee(q,Q.adler>>>16),ee(q,65535&Q.adler)),Q.adler=1}if(q.status===69)if(q.gzhead.extra){for(J=q.pending;q.gzindex<(65535&q.gzhead.extra.length)&&(q.pending!==q.pending_buf_size||(q.gzhead.hcrc&&q.pending>J&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),O(Q),J=q.pending,q.pending!==q.pending_buf_size));)W(q,255&q.gzhead.extra[q.gzindex]),q.gzindex++;q.gzhead.hcrc&&q.pending>J&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),q.gzindex===q.gzhead.extra.length&&(q.gzindex=0,q.status=73)}else q.status=73;if(q.status===73)if(q.gzhead.name){J=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>J&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),O(Q),J=q.pending,q.pending===q.pending_buf_size)){ce=1;break}ce=q.gzindexJ&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),ce===0&&(q.gzindex=0,q.status=91)}else q.status=91;if(q.status===91)if(q.gzhead.comment){J=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>J&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),O(Q),J=q.pending,q.pending===q.pending_buf_size)){ce=1;break}ce=q.gzindexJ&&(Q.adler=A(Q.adler,q.pending_buf,q.pending-J,J)),ce===0&&(q.status=103)}else q.status=103;if(q.status===103&&(q.gzhead.hcrc?(q.pending+2>q.pending_buf_size&&O(Q),q.pending+2<=q.pending_buf_size&&(W(q,255&Q.adler),W(q,Q.adler>>8&255),Q.adler=0,q.status=I)):q.status=I),q.pending!==0){if(O(Q),Q.avail_out===0)return q.last_flush=-1,h}else if(Q.avail_in===0&&z(de)<=z(Ae)&&de!==f)return L(Q,-5);if(q.status===666&&Q.avail_in!==0)return L(Q,-5);if(Q.avail_in!==0||q.lookahead!==0||de!==u&&q.status!==666){var be=q.strategy===2?function(N,j){for(var se;;){if(N.lookahead===0&&(X(N),N.lookahead===0)){if(j===u)return v;break}if(N.match_length=0,se=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++,se&&(B(N,!1),N.strm.avail_out===0))return v}return N.insert=0,j===f?(B(N,!0),N.strm.avail_out===0?U:P):N.last_lit&&(B(N,!1),N.strm.avail_out===0)?v:E}(q,de):q.strategy===3?function(N,j){for(var se,he,me,G,R=N.window;;){if(N.lookahead<=D){if(X(N),N.lookahead<=D&&j===u)return v;if(N.lookahead===0)break}if(N.match_length=0,N.lookahead>=M&&0N.lookahead&&(N.match_length=N.lookahead)}if(N.match_length>=M?(se=a._tr_tally(N,1,N.match_length-M),N.lookahead-=N.match_length,N.strstart+=N.match_length,N.match_length=0):(se=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++),se&&(B(N,!1),N.strm.avail_out===0))return v}return N.insert=0,j===f?(B(N,!0),N.strm.avail_out===0?U:P):N.last_lit&&(B(N,!1),N.strm.avail_out===0)?v:E}(q,de):s[q.level].func(q,de);if(be!==U&&be!==P||(q.status=666),be===v||be===U)return Q.avail_out===0&&(q.last_flush=-1),h;if(be===E&&(de===1?a._tr_align(q):de!==5&&(a._tr_stored_block(q,0,0,!1),de===3&&(K(q.head),q.lookahead===0&&(q.strstart=0,q.block_start=0,q.insert=0))),O(Q),Q.avail_out===0))return q.last_flush=-1,h}return de!==f?h:q.wrap<=0?1:(q.wrap===2?(W(q,255&Q.adler),W(q,Q.adler>>8&255),W(q,Q.adler>>16&255),W(q,Q.adler>>24&255),W(q,255&Q.total_in),W(q,Q.total_in>>8&255),W(q,Q.total_in>>16&255),W(q,Q.total_in>>24&255)):(ee(q,Q.adler>>>16),ee(q,65535&Q.adler)),O(Q),0=Ae.w_size&&(ce===0&&(K(Ae.head),Ae.strstart=0,Ae.block_start=0,Ae.insert=0),j=new o.Buf8(Ae.w_size),o.arraySet(j,de,se-Ae.w_size,Ae.w_size,0),de=j,se=Ae.w_size),xe=Q.avail_in,be=Q.next_in,N=Q.input,Q.avail_in=se,Q.next_in=0,Q.input=de,X(Ae);Ae.lookahead>=M;){for(q=Ae.strstart,J=Ae.lookahead-(M-1);Ae.ins_h=(Ae.ins_h<>>=M=b>>>24,w-=M,(M=b>>>16&255)===0)E[c++]=65535&b;else{if(!(16&M)){if(!(64&M)){b=x[(65535&b)+(y&(1<>>=M,w-=M),w<15&&(y+=v[l++]<>>=M=b>>>24,w-=M,!(16&(M=b>>>16&255))){if(!(64&M)){b=_[(65535&b)+(y&(1<>>=M,w-=M,(M=c-u)<$){if(d<(M=$-M)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(I=m,(H=0)===g){if(H+=p-M,M>3,y&=(1<<(w-=D<<3))-1,s.next_in=l,s.next_out=c,s.avail_in=l>>24&255)+(H>>>8&65280)+((65280&H)<<8)+((255&H)<<24)}function y(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(H){var I;return H&&H.state?(I=H.state,H.total_in=H.total_out=I.total=0,H.msg="",I.wrap&&(H.adler=1&I.wrap),I.mode=p,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new s.Buf32(d),I.distcode=I.distdyn=new s.Buf32(g),I.sane=1,I.back=-1,f):h}function x(H){var I;return H&&H.state?((I=H.state).wsize=0,I.whave=0,I.wnext=0,w(H)):h}function _(H,I){var v,E;return H&&H.state?(E=H.state,I<0?(v=0,I=-I):(v=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15=P.wsize?(s.arraySet(P.window,I,v-P.wsize,P.wsize,0),P.wnext=0,P.whave=P.wsize):(E<(U=P.wsize-P.wnext)&&(U=E),s.arraySet(P.window,I,v-E,U,P.wnext),(E-=U)?(s.arraySet(P.window,I,v-E,E,0),P.wnext=E,P.whave=P.wsize):(P.wnext+=U,P.wnext===P.wsize&&(P.wnext=0),P.whave>>8&255,v.check=a(v.check,ce,2,0),B=O=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&O)<<8)+(O>>8))%31){H.msg="incorrect header check",v.mode=30;break}if((15&O)!=8){H.msg="unknown compression method",v.mode=30;break}if(B-=4,Q=8+(15&(O>>>=4)),v.wbits===0)v.wbits=Q;else if(Q>v.wbits){H.msg="invalid window size",v.mode=30;break}v.dmax=1<>8&1),512&v.flags&&(ce[0]=255&O,ce[1]=O>>>8&255,v.check=a(v.check,ce,2,0)),B=O=0,v.mode=3;case 3:for(;B<32;){if(z===0)break e;z--,O+=E[P++]<>>8&255,ce[2]=O>>>16&255,ce[3]=O>>>24&255,v.check=a(v.check,ce,4,0)),B=O=0,v.mode=4;case 4:for(;B<16;){if(z===0)break e;z--,O+=E[P++]<>8),512&v.flags&&(ce[0]=255&O,ce[1]=O>>>8&255,v.check=a(v.check,ce,2,0)),B=O=0,v.mode=5;case 5:if(1024&v.flags){for(;B<16;){if(z===0)break e;z--,O+=E[P++]<>>8&255,v.check=a(v.check,ce,2,0)),B=O=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(z<(F=v.length)&&(F=z),F&&(v.head&&(Q=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),s.arraySet(v.head.extra,E,P,F,Q)),512&v.flags&&(v.check=a(v.check,E,F,P)),z-=F,P+=F,v.length-=F),v.length))break e;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(z===0)break e;for(F=0;Q=E[P+F++],v.head&&Q&&v.length<65536&&(v.head.name+=String.fromCharCode(Q)),Q&&F>9&1,v.head.done=!0),H.adler=v.check=0,v.mode=12;break;case 10:for(;B<32;){if(z===0)break e;z--,O+=E[P++]<>>=7&B,B-=7&B,v.mode=27;break}for(;B<3;){if(z===0)break e;z--,O+=E[P++]<>>=1)){case 0:v.mode=14;break;case 1:if(D(v),v.mode=20,I!==6)break;O>>>=2,B-=2;break e;case 2:v.mode=17;break;case 3:H.msg="invalid block type",v.mode=30}O>>>=2,B-=2;break;case 14:for(O>>>=7&B,B-=7&B;B<32;){if(z===0)break e;z--,O+=E[P++]<>>16^65535)){H.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&O,B=O=0,v.mode=15,I===6)break e;case 15:v.mode=16;case 16:if(F=v.length){if(z>>=5,B-=5,v.ndist=1+(31&O),O>>>=5,B-=5,v.ncode=4+(15&O),O>>>=4,B-=4,286>>=3,B-=3}for(;v.have<19;)v.lens[xe[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,Ae={bits:v.lenbits},de=A(0,v.lens,0,19,v.lencode,0,v.work,Ae),v.lenbits=Ae.bits,de){H.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have>>16&255,re=65535&J,!((le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>>=le,B-=le,v.lens[v.have++]=re;else{if(re===16){for(q=le+2;B>>=le,B-=le,v.have===0){H.msg="invalid bit length repeat",v.mode=30;break}Q=v.lens[v.have-1],F=3+(3&O),O>>>=2,B-=2}else if(re===17){for(q=le+3;B>>=le)),O>>>=3,B-=3}else{for(q=le+7;B>>=le)),O>>>=7,B-=7}if(v.have+F>v.nlen+v.ndist){H.msg="invalid bit length repeat",v.mode=30;break}for(;F--;)v.lens[v.have++]=Q}}if(v.mode===30)break;if(v.lens[256]===0){H.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,Ae={bits:v.lenbits},de=A(c,v.lens,0,v.nlen,v.lencode,0,v.work,Ae),v.lenbits=Ae.bits,de){H.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,Ae={bits:v.distbits},de=A(u,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,Ae),v.distbits=Ae.bits,de){H.msg="invalid distances set",v.mode=30;break}if(v.mode=20,I===6)break e;case 20:v.mode=21;case 21:if(6<=z&&258<=K){H.next_out=L,H.avail_out=K,H.next_in=P,H.avail_in=z,v.hold=O,v.bits=B,l(H,ee),L=H.next_out,U=H.output,K=H.avail_out,P=H.next_in,E=H.input,z=H.avail_in,O=v.hold,B=v.bits,v.mode===12&&(v.back=-1);break}for(v.back=0;oe=(J=v.lencode[O&(1<>>16&255,re=65535&J,!((le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>pe)])>>>16&255,re=65535&J,!(pe+(le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>>=pe,B-=pe,v.back+=pe}if(O>>>=le,B-=le,v.back+=le,v.length=re,oe===0){v.mode=26;break}if(32&oe){v.back=-1,v.mode=12;break}if(64&oe){H.msg="invalid literal/length code",v.mode=30;break}v.extra=15&oe,v.mode=22;case 22:if(v.extra){for(q=v.extra;B>>=v.extra,B-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;oe=(J=v.distcode[O&(1<>>16&255,re=65535&J,!((le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>pe)])>>>16&255,re=65535&J,!(pe+(le=J>>>24)<=B);){if(z===0)break e;z--,O+=E[P++]<>>=pe,B-=pe,v.back+=pe}if(O>>>=le,B-=le,v.back+=le,64&oe){H.msg="invalid distance code",v.mode=30;break}v.offset=re,v.extra=15&oe,v.mode=24;case 24:if(v.extra){for(q=v.extra;B>>=v.extra,B-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){H.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(K===0)break e;if(F=ee-K,v.offset>F){if((F=v.offset-F)>v.whave&&v.sane){H.msg="invalid distance too far back",v.mode=30;break}X=F>v.wnext?(F-=v.wnext,v.wsize-F):v.wnext-F,F>v.length&&(F=v.length),ue=v.window}else ue=U,X=L-v.offset,F=v.length;for(KS?(M=X[ue+g[I]],B[W+g[I]]):(M=96,0),y=1<>L)+(w-=y)]=b<<24|M<<16|D|0,w!==0;);for(y=1<>=1;if(y!==0?(O&=y-1,O+=y):O=0,I++,--ee[H]==0){if(H===E)break;H=u[f+g[I]]}if(U>>7)]}function W(J,ce){J.pending_buf[J.pending++]=255&ce,J.pending_buf[J.pending++]=ce>>>8&255}function ee(J,ce,xe){J.bi_valid>m-xe?(J.bi_buf|=ce<>m-J.bi_valid,J.bi_valid+=xe-m):(J.bi_buf|=ce<>>=1,xe<<=1,0<--ce;);return xe>>>1}function ue(J,ce,xe){var be,N,j=new Array(g+1),se=0;for(be=1;be<=g;be++)j[be]=se=se+xe[be-1]<<1;for(N=0;N<=ce;N++){var he=J[2*N+1];he!==0&&(J[2*N]=X(j[he]++,he))}}function le(J){var ce;for(ce=0;ce>1;1<=xe;xe--)pe(J,j,xe);for(N=me;xe=J.heap[1],J.heap[1]=J.heap[J.heap_len--],pe(J,j,1),be=J.heap[1],J.heap[--J.heap_max]=xe,J.heap[--J.heap_max]=be,j[2*N]=j[2*xe]+j[2*be],J.depth[N]=(J.depth[xe]>=J.depth[be]?J.depth[xe]:J.depth[be])+1,j[2*xe+1]=j[2*be+1]=N,J.heap[1]=N++,pe(J,j,1),2<=J.heap_len;);J.heap[--J.heap_max]=J.heap[1],function(R,T){var V,te,ae,ie,Te,Me,Le=T.dyn_tree,ke=T.max_code,De=T.stat_desc.static_tree,fe=T.stat_desc.has_stree,Ce=T.stat_desc.extra_bits,Se=T.stat_desc.extra_base,Fe=T.stat_desc.max_length,We=0;for(ie=0;ie<=g;ie++)R.bl_count[ie]=0;for(Le[2*R.heap[R.heap_max]+1]=0,V=R.heap_max+1;V>=7;N>>=1)if(1&G&&he.dyn_ltree[2*me]!==0)return o;if(he.dyn_ltree[18]!==0||he.dyn_ltree[20]!==0||he.dyn_ltree[26]!==0)return a;for(me=32;me>>3,(j=J.static_len+3+7>>>3)<=N&&(N=j)):N=j=xe+5,xe+4<=N&&ce!==-1?q(J,ce,xe,be):J.strategy===4||j===N?(ee(J,2+(be?1:0),3),_e(J,$,H)):(ee(J,4+(be?1:0),3),function(he,me,G,R){var T;for(ee(he,me-257,5),ee(he,G-1,5),ee(he,R-4,4),T=0;T>>8&255,J.pending_buf[J.d_buf+2*J.last_lit+1]=255&ce,J.pending_buf[J.l_buf+J.last_lit]=255&xe,J.last_lit++,ce===0?J.dyn_ltree[2*xe]++:(J.matches++,ce--,J.dyn_ltree[2*(v[xe]+u+1)]++,J.dyn_dtree[2*B(ce)]++),J.last_lit===J.lit_bufsize-1},i._tr_align=function(J){ee(J,2,3),F(J,w,$),function(ce){ce.bi_valid===16?(W(ce,ce.bi_buf),ce.bi_buf=0,ce.bi_valid=0):8<=ce.bi_valid&&(ce.pending_buf[ce.pending++]=255&ce.bi_buf,ce.bi_buf>>=8,ce.bi_valid-=8)}(J)}},{"../utils/common":41}],53:[function(t,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,r,i){(function(s){(function(o,a){if(!o.setImmediate){var l,A,c,u,f=1,h={},p=!1,d=o.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(o);g=g&&g.setTimeout?g:o,l={}.toString.call(o.process)==="[object process]"?function(x){process.nextTick(function(){y(x)})}:function(){if(o.postMessage&&!o.importScripts){var x=!0,_=o.onmessage;return o.onmessage=function(){x=!1},o.postMessage("","*"),o.onmessage=_,x}}()?(u="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",w,!1):o.attachEvent("onmessage",w),function(x){o.postMessage(u+x,"*")}):o.MessageChannel?((c=new MessageChannel).port1.onmessage=function(x){y(x.data)},function(x){c.port2.postMessage(x)}):d&&"onreadystatechange"in d.createElement("script")?(A=d.documentElement,function(x){var _=d.createElement("script");_.onreadystatechange=function(){y(x),_.onreadystatechange=null,A.removeChild(_),_=null},A.appendChild(_)}):function(x){setTimeout(y,0,x)},g.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var _=new Array(arguments.length-1),C=0;C<_.length;C++)_[C]=arguments[C+1];var S={callback:x,args:_};return h[f]=S,l(f),f++},g.clearImmediate=m}function m(x){delete h[x]}function y(x){if(p)setTimeout(y,0,x);else{var _=h[x];if(_){p=!0;try{(function(C){var S=C.callback,b=C.args;switch(b.length){case 0:S();break;case 1:S(b[0]);break;case 2:S(b[0],b[1]);break;case 3:S(b[0],b[1],b[2]);break;default:S.apply(a,b)}})(_)}finally{m(x),p=!1}}}}function w(x){x.source===o&&typeof x.data=="string"&&x.data.indexOf(u)===0&&y(+x.data.slice(u.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof ta<"u"?ta:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(P5);var fhe=P5.exports;const hhe=bl(fhe);class ad{constructor(){this.zipContainer={}}addData(e,t,r,i=""){i==""&&(i="_"),this.zipContainer[i]==null&&(this.zipContainer[i]=[]),this.zipContainer[i].push({data:e,name:t,extension:r})}saveZip(e,t=!0){const r=this.zipContainer,i=new hhe;for(const s in r)if(s=="_")r[s].forEach((o,a)=>{i.file(o.name+"."+o.extension,o.data,{base64:!0})});else{const o=i.folder(s);r[s].forEach((a,l)=>{const A=a.extension!="txt";o.file(a.name+"."+a.extension,a.data,{base64:A})})}i.generateAsync({type:"blob"}).then(s=>{this._saveZipFile(s,e+".zip")}),t&&(this.zipContainer={})}_saveZipFile(e,t){const r=new Blob([e],{type:"application/zip"});if(typeof window.navigator.msSaveBlob<"u")window.navigator.msSaveBlob(r,t);else{const i=document.createElement("a");typeof i.download=="string"?(document.body.appendChild(i),i.download=t,i.href=URL.createObjectURL(r),i.click(),document.body.removeChild(i)):window.open(e,"_blank").document.write(""+t+"")}}}new Z;class dhe{constructor(e){this.characterManager=e,this.screenshotManager=e.screenshotManager,this.blinkManager=e.blinkManager,this.animationManager=this.characterManager.animationManager,this.temptime=0}async createLoraData(e,t=null,r="",i){const s=e.manifest,o=e.name?"loraData/"+e.name:"loraData",a=await this._fetchManifest(s),{assetsLocation:l="",animationsDirectory:A="",backgroundGrayscale:c=1,topFrameOffsetPixels:u=64,bottomFrameOffsetPixels:f=64,backgroundDescription:h="",width:p=512,height:d=512,dataCollection:g}=a,m=l+A+"/";this.screenshotManager.setBackground([c,c,c]),this.blinkManager.enableScreenshot(),await this.screenshotManager.calculateBoneOffsets(.2);let y=0;const w=this;if(Array.isArray(g)){const x=t??new ad;await(async()=>{if(Array.isArray(g))for(let C=0;C{const K=[];return ct(U).forEach(B=>{K.push({id:B})}),K},L=U==null?y.characterManager.getTraits(S):P();if(L==null){console.log("SKipping Thumbnail Generation for trait group "+S+", its not present in the character manifest.");continue}const z=wT(b);E?y.screenshotManager.setCameraFrameWithName(E,z):y.screenshotManager.frameShot(M,$,z,D,H);for(let K=0;K{const[e,t]=ye.useState(null),[r,i]=ye.useState(null),[s,o]=ye.useState(null),[a,l]=ye.useState(null),[A,c]=ye.useState(null),[u,f]=ye.useState(null),[h,p]=ye.useState(null),[d,g]=ye.useState(null),[m,y]=ye.useState(null),[w,x]=ye.useState(null),[_,C]=ye.useState(null),[S,b]=ye.useState(!1);let M=!1,[D,$]=ye.useState(!1);ye.useEffect(()=>{if(M||D)return;$(!0),M=!0;const{scene:E,camera:U,controls:P,characterManager:L,sceneElements:z}=uhe("editor-scene");y(U),g(E),t(L),c(z),f(L.animationManager),p(L.lookAtManager),x(P),i(new dhe(L)),o(new phe(L)),l(new mhe(L))},[]);const H=E=>{E==null&&(E=!S),b(E),d.traverse(U=>{U.isMesh&&U.setDebugMode&&U.setDebugMode(E)})};ye.useEffect(()=>{if(_!=null&&_.defaultAnimations){const E=_.defaultAnimations.map(U=>U.location);u.storeDefaultAnimationPaths(E,"")}},[_]);const I=E=>{E?d.add(A):d.remove(A)},v=E=>{w&&(tC.to(w.target,{x:E.targetX??0,y:E.targetY??0,z:E.targetZ??0,duration:1}),tC.fromTo(w,{maxDistance:w.getDistance(),minDistance:w.getDistance(),minPolarAngle:w.getPolarAngle(),maxPolarAngle:w.getPolarAngle(),minAzimuthAngle:w.getAzimuthalAngle(),maxAzimuthAngle:w.getAzimuthalAngle()},{maxDistance:E.distance,minDistance:E.distance,minPolarAngle:Math.PI/2-.11,maxPolarAngle:Math.PI/2-.11,minAzimuthAngle:-.78,maxAzimuthAngle:-.78,duration:1}).then(()=>{w.minPolarAngle=0,w.maxPolarAngle=3.1415,w.minDistance=.5,w.maxDistance=10,w.minAzimuthAngle=1/0,w.maxAzimuthAngle=1/0}))};return k.jsx(or.Provider,{value:{manifest:_,setManifest:C,scene:d,characterManager:e,loraDataGenerator:r,spriteAtlasGenerator:s,thumbnailsGenerator:a,showEnvironmentModels:I,debugMode:S,toggleDebugMode:H,animationManager:u,lookAtManager:h,camera:m,moveCamera:v,controls:w,sceneElements:A},children:n.children})},vhe={NORMAL:"NORMAL",AR:"AR",AR_FRONT:"AR_FRONT",VR:"VR"},dt={LANDING:"LANDING",CREATE:"CREATE",CLAIM:"CLAIM",LOAD:"LOAD",APPEARANCE:"APPEARANCE",BATCHDOWNLOAD:"BATCHDOWNLOAD",SAVE:"SAVE",MINT:"MINT",OPTIMIZER:"OPTIMIZER",BATCHMANIFEST:"BATCHMANIFEST",WALLET:"WALLET"},Ui=Y.createContext(),yhe=n=>{const[e,t]=Y.useState(vhe.NORMAL),[r,i]=Y.useState(dt.LANDING),[s,o]=Y.useState(!1),[a,l]=Y.useState(!1);return k.jsx(Ui.Provider,{value:{viewMode:r,setViewMode:i,isLoading:s,setIsLoading:o,mouseIsOverUI:a,setMouseIsOverUI:l,currentCameraMode:e,setCurrentCameraMode:t},children:n.children})},whe="modulepreload",xhe=function(n){return"/CharacterStudio/"+n},q3={},_he=function(e,t,r){if(!t||t.length===0)return e();const i=document.getElementsByTagName("link");return Promise.all(t.map(s=>{if(s=xhe(s),s in q3)return;q3[s]=!0;const o=s.endsWith(".css"),a=o?'[rel="stylesheet"]':"";if(!!r)for(let c=i.length-1;c>=0;c--){const u=i[c];if(u.href===s&&(!o||u.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${a}`))return;const A=document.createElement("link");if(A.rel=o?"stylesheet":whe,o||(A.as="script",A.crossOrigin=""),A.href=s,document.head.appendChild(A),o)return new Promise((c,u)=>{A.addEventListener("load",c),A.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${s}`)))})})).then(()=>e()).catch(s=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s})};function zw(){return zw=Object.assign||function(n){for(var e=1;e=0)&&(t[i]=n[i]);return t}function Bhe(n){ye.useEffect(n,[])}function Ehe(n,e){e===void 0&&(e={});var t=e,r=t.volume,i=r===void 0?1:r,s=t.playbackRate,o=s===void 0?1:s,a=t.soundEnabled,l=a===void 0?!0:a,A=t.interrupt,c=A===void 0?!1:A,u=t.onload,f=bhe(t,["id","volume","playbackRate","soundEnabled","interrupt","onload"]),h=Y.useRef(null),p=Y.useRef(!1),d=Y.useState(null),g=d[0],m=d[1],y=Y.useState(null),w=y[0],x=y[1],_=function(){typeof u=="function"&&u.call(this),p.current&&m(this.duration()*1e3),x(this)};Bhe(function(){return _he(()=>import("./howler-1fccfb1e.js").then(D=>D.h),[]).then(function(D){if(!p.current){var $;h.current=($=D.Howl)!==null&&$!==void 0?$:D.default.Howl,p.current=!0,new h.current(zw({src:Array.isArray(n)?n:[n],volume:i,rate:o,onload:_},f))}}),function(){p.current=!1}}),Y.useEffect(function(){h.current&&w&&x(new h.current(zw({src:Array.isArray(n)?n:[n],volume:i,onload:_},f)))},[JSON.stringify(n)]),Y.useEffect(function(){w&&(w.volume(i),w.rate(o))},[i,o]);var C=Y.useCallback(function(D){typeof D>"u"&&(D={}),!(!w||!l&&!D.forceSoundEnabled)&&(c&&w.stop(),D.playbackRate&&w.rate(D.playbackRate),w.play(D.id))},[w,l,c]),S=Y.useCallback(function(D){w&&w.stop(D)},[w]),b=Y.useCallback(function(D){w&&w.pause(D)},[w]),M=[C,{sound:w,stop:S,pause:b,duration:g}];return M}const Che=[{name:"background/cc_bgm.wav",offset:0,duration:123458.58333333334},{name:"background/cc_bgm_balanced.wav",offset:123458.58333333334,duration:123458.60416666666},{name:"effect/character-load.wav",offset:246917.1875,duration:3030},{name:"effect/class-select.wav",offset:249947.1875,duration:2780},{name:"effect/switchingItem.wav",offset:252727.1875,duration:623.75},{name:"ui/back-next-button.wav",offset:253350.9375,duration:155.02083333333334},{name:"ui/class-mouse-over.wav",offset:253505.95833333334,duration:217.52083333333334},{name:"ui/class_click.wav",offset:253723.4791666667,duration:3123.75},{name:"ui/class_pass.wav",offset:256847.2291666667,duration:155},{name:"ui/option_click.wav",offset:257002.2291666667,duration:155.02083333333334},{name:"ui/randomize-button.wav",offset:257157.25000000003,duration:342.5208333333333},{name:"ui/section_click.wav",offset:257499.77083333337,duration:155}],She="/CharacterStudio/assets/sounds-3322d50e.mp3",Ys=ye.createContext(),Mhe=n=>{const e=i=>Che.find(s=>i.test(s.name)),[t]=Ehe(She,{sprite:{switchItem:[e(/switchingItem/).offset,e(/switchingItem/).duration],classSelect:[e(/class-select/).offset,e(/class-select/).duration],characterLoad:[e(/character-load/).offset,e(/character-load/).duration],randomizeButton:[e(/randomize-button/).offset,e(/randomize-button/).duration],classMouseOver:[e(/class-mouse-over/).offset,e(/class-mouse-over/).duration],backNextButton:[e(/back-next-button/).offset,e(/back-next-button/).duration]}}),r=(i,s=0)=>{s===0?t({id:i}):setTimeout(()=>{t({id:i})},s)};return k.jsx(Ys.Provider,{value:{playSound:r},children:n.children})};function ks(n){"@babel/helpers - typeof";return ks=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ks(n)}function Xs(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function The(n,e){if(ks(n)!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(ks(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function D5(n){var e=The(n,"string");return ks(e)=="symbol"?e:e+""}function eP(n,e){for(var t=0;tn.length)&&(e=n.length);for(var t=0,r=new Array(e);t1&&arguments[1]!==void 0?arguments[1]:{};Xs(this,n),this.init(e,t)}return Zs(n,[{key:"init",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=r.prefix||"i18next:",this.logger=t||Fhe,this.options=r,this.debug=r.debug}},{key:"setDebug",value:function(t){this.debug=t}},{key:"log",value:function(){for(var t=arguments.length,r=new Array(t),i=0;i1?r-1:0),s=1;s-1?a.replace(/###/g,"."):a}function i(){return!n||typeof n=="string"}for(var s=typeof e!="string"?[].concat(e):e.split(".");s.length>1;){if(i())return{};var o=r(s.shift());!n[o]&&t&&(n[o]=new t),Object.prototype.hasOwnProperty.call(n,o)?n=n[o]:n={}}return i()?{}:{obj:n,k:r(s.shift())}}function sP(n,e,t){var r=ET(n,e,Object),i=r.obj,s=r.k;i[s]=t}function Phe(n,e,t,r){var i=ET(n,e,Object),s=i.obj,o=i.k;s[o]=s[o]||[],r&&(s[o]=s[o].concat(t)),r||s[o].push(t)}function Gw(n,e){var t=ET(n,e),r=t.obj,i=t.k;if(r)return r[i]}function oP(n,e,t){var r=Gw(n,t);return r!==void 0?r:Gw(e,t)}function Q5(n,e,t){for(var r in e)r!=="__proto__"&&r!=="constructor"&&(r in n?typeof n[r]=="string"||n[r]instanceof String||typeof e[r]=="string"||e[r]instanceof String?t&&(n[r]=e[r]):Q5(n[r],e[r],t):n[r]=e[r]);return n}function Zu(n){return n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var Dhe={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function Ohe(n){return typeof n=="string"?n.replace(/[&<>"'\/]/g,function(e){return Dhe[e]}):n}var o_=typeof window<"u"&&window.navigator&&typeof window.navigator.userAgentData>"u"&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Nhe=[" ",",","?","!",";"];function khe(n,e,t){e=e||"",t=t||"";var r=Nhe.filter(function(a){return e.indexOf(a)<0&&t.indexOf(a)<0});if(r.length===0)return!0;var i=new RegExp("(".concat(r.map(function(a){return a==="?"?"\\?":a}).join("|"),")")),s=!i.test(n);if(!s){var o=n.indexOf(t);o>0&&!i.test(n.substring(0,o))&&(s=!0)}return s}function aP(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function _v(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function H5(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(n){if(n[e])return n[e];for(var r=e.split(t),i=n,s=0;ss+o;)o++,a=r.slice(s,s+o).join(t),l=i[a];if(l===void 0)return;if(l===null)return null;if(e.endsWith(a)){if(typeof l=="string")return l;if(a&&typeof l[a]=="string")return l[a]}var A=r.slice(s+o).join(t);return A?H5(l,A,t):void 0}i=i[r[s]]}return i}}var zhe=function(n){s_(t,n);var e=Qhe(t);function t(r){var i,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};return Xs(this,t),i=e.call(this),o_&&QA.call(IA(i)),i.data=r||{},i.options=s,i.options.keySeparator===void 0&&(i.options.keySeparator="."),i.options.ignoreJSONStructure===void 0&&(i.options.ignoreJSONStructure=!0),i}return Zs(t,[{key:"addNamespaces",value:function(i){this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}},{key:"removeNamespaces",value:function(i){var s=this.options.ns.indexOf(i);s>-1&&this.options.ns.splice(s,1)}},{key:"getResource",value:function(i,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},l=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,A=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,c=[i,s];o&&typeof o!="string"&&(c=c.concat(o)),o&&typeof o=="string"&&(c=c.concat(l?o.split(l):o)),i.indexOf(".")>-1&&(c=i.split("."));var u=Gw(this.data,c);return u||!A||typeof o!="string"?u:H5(this.data&&this.data[i]&&this.data[i][s],o,l)}},{key:"addResource",value:function(i,s,o,a){var l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},A=this.options.keySeparator;A===void 0&&(A=".");var c=[i,s];o&&(c=c.concat(A?o.split(A):o)),i.indexOf(".")>-1&&(c=i.split("."),a=s,s=c[1]),this.addNamespaces(s),sP(this.data,c,a),l.silent||this.emit("added",i,s,o,a)}},{key:"addResources",value:function(i,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(var l in o)(typeof o[l]=="string"||Object.prototype.toString.apply(o[l])==="[object Array]")&&this.addResource(i,s,l,o[l],{silent:!0});a.silent||this.emit("added",i,s,o)}},{key:"addResourceBundle",value:function(i,s,o,a,l){var A=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},c=[i,s];i.indexOf(".")>-1&&(c=i.split("."),a=o,o=s,s=c[1]),this.addNamespaces(s);var u=Gw(this.data,c)||{};a?Q5(u,o,l):u=_v(_v({},u),o),sP(this.data,c,u),A.silent||this.emit("added",i,s,o)}},{key:"removeResourceBundle",value:function(i,s){this.hasResourceBundle(i,s)&&delete this.data[i][s],this.removeNamespaces(s),this.emit("removed",i,s)}},{key:"hasResourceBundle",value:function(i,s){return this.getResource(i,s)!==void 0}},{key:"getResourceBundle",value:function(i,s){return s||(s=this.options.defaultNS),this.options.compatibilityAPI==="v1"?_v(_v({},{}),this.getResource(i,s)):this.getResource(i,s)}},{key:"getDataByLanguage",value:function(i){return this.data[i]}},{key:"hasLanguageSomeTranslations",value:function(i){var s=this.getDataByLanguage(i),o=s&&Object.keys(s)||[];return!!o.find(function(a){return s[a]&&Object.keys(s[a]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),t}(QA),z5={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,r,i,s){var o=this;return e.forEach(function(a){o.processors[a]&&(t=o.processors[a].process(t,r,i,s))}),t}};function lP(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function ni(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var AP={},cP=function(n){s_(t,n);var e=Ghe(t);function t(r){var i,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Xs(this,t),i=e.call(this),o_&&QA.call(IA(i)),Lhe(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r,IA(i)),i.options=s,i.options.keySeparator===void 0&&(i.options.keySeparator="."),i.logger=na.create("translator"),i}return Zs(t,[{key:"changeLanguage",value:function(i){i&&(this.language=i)}},{key:"exists",value:function(i){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(i==null)return!1;var o=this.resolve(i,s);return o&&o.res!==void 0}},{key:"extractFromKey",value:function(i,s){var o=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");var a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,l=s.ns||this.options.defaultNS||[],A=o&&i.indexOf(o)>-1,c=!this.options.userDefinedKeySeparator&&!s.keySeparator&&!this.options.userDefinedNsSeparator&&!s.nsSeparator&&!khe(i,o,a);if(A&&!c){var u=i.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:i,namespaces:l};var f=i.split(o);(o!==a||o===a&&this.options.ns.indexOf(f[0])>-1)&&(l=f.shift()),i=f.join(a)}return typeof l=="string"&&(l=[l]),{key:i,namespaces:l}}},{key:"translate",value:function(i,s,o){var a=this;if(ks(s)!=="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),s||(s={}),i==null)return"";Array.isArray(i)||(i=[String(i)]);var l=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,A=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,c=this.extractFromKey(i[i.length-1],s),u=c.key,f=c.namespaces,h=f[f.length-1],p=s.lng||this.language,d=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(p&&p.toLowerCase()==="cimode"){if(d){var g=s.nsSeparator||this.options.nsSeparator;return l?{res:"".concat(h).concat(g).concat(u),usedKey:u,exactUsedKey:u,usedLng:p,usedNS:h}:"".concat(h).concat(g).concat(u)}return l?{res:u,usedKey:u,exactUsedKey:u,usedLng:p,usedNS:h}:u}var m=this.resolve(i,s),y=m&&m.res,w=m&&m.usedKey||u,x=m&&m.exactUsedKey||u,_=Object.prototype.toString.apply(y),C=["[object Number]","[object Function]","[object RegExp]"],S=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,M=typeof y!="string"&&typeof y!="boolean"&&typeof y!="number";if(b&&y&&M&&C.indexOf(_)<0&&!(typeof S=="string"&&_==="[object Array]")){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var D=this.options.returnedObjectHandler?this.options.returnedObjectHandler(w,y,ni(ni({},s),{},{ns:f})):"key '".concat(u," (").concat(this.language,")' returned an object instead of string.");return l?(m.res=D,m):D}if(A){var $=_==="[object Array]",H=$?[]:{},I=$?x:w;for(var v in y)if(Object.prototype.hasOwnProperty.call(y,v)){var E="".concat(I).concat(A).concat(v);H[v]=this.translate(E,ni(ni({},s),{joinArrays:!1,ns:f})),H[v]===E&&(H[v]=y[v])}y=H}}else if(b&&typeof S=="string"&&_==="[object Array]")y=y.join(S),y&&(y=this.extendTranslation(y,i,s,o));else{var U=!1,P=!1,L=s.count!==void 0&&typeof s.count!="string",z=t.hasDefaultValue(s),K=L?this.pluralResolver.getSuffix(p,s.count,s):"",O=s["defaultValue".concat(K)]||s.defaultValue;!this.isValidLookup(y)&&z&&(U=!0,y=O),this.isValidLookup(y)||(P=!0,y=u);var B=s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey,W=B&&P?void 0:y,ee=z&&O!==y&&this.options.updateMissing;if(P||U||ee){if(this.logger.log(ee?"updateKey":"missingKey",p,h,u,ee?O:y),A){var F=this.resolve(u,ni(ni({},s),{},{keySeparator:!1}));F&&F.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var X=[],ue=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&ue&&ue[0])for(var le=0;le1&&arguments[1]!==void 0?arguments[1]:{},a,l,A,c,u;return typeof i=="string"&&(i=[i]),i.forEach(function(f){if(!s.isValidLookup(a)){var h=s.extractFromKey(f,o),p=h.key;l=p;var d=h.namespaces;s.options.fallbackNS&&(d=d.concat(s.options.fallbackNS));var g=o.count!==void 0&&typeof o.count!="string",m=g&&!o.ordinal&&o.count===0&&s.pluralResolver.shouldUseIntlApi(),y=o.context!==void 0&&(typeof o.context=="string"||typeof o.context=="number")&&o.context!=="",w=o.lngs?o.lngs:s.languageUtils.toResolveHierarchy(o.lng||s.language,o.fallbackLng);d.forEach(function(x){s.isValidLookup(a)||(u=x,!AP["".concat(w[0],"-").concat(x)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(u)&&(AP["".concat(w[0],"-").concat(x)]=!0,s.logger.warn('key "'.concat(l,'" for languages "').concat(w.join(", "),`" won't get resolved as namespace "`).concat(u,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),w.forEach(function(_){if(!s.isValidLookup(a)){c=_;var C=[p];if(s.i18nFormat&&s.i18nFormat.addLookupKeys)s.i18nFormat.addLookupKeys(C,p,_,x,o);else{var S;g&&(S=s.pluralResolver.getSuffix(_,o.count,o));var b="".concat(s.options.pluralSeparator,"zero");if(g&&(C.push(p+S),m&&C.push(p+b)),y){var M="".concat(p).concat(s.options.contextSeparator).concat(o.context);C.push(M),g&&(C.push(M+S),m&&C.push(M+b))}}for(var D;D=C.pop();)s.isValidLookup(a)||(A=D,a=s.getResource(_,x,D,o))}}))})}}),{res:a,usedKey:l,exactUsedKey:A,usedLng:c,usedNS:u}}},{key:"isValidLookup",value:function(i){return i!==void 0&&!(!this.options.returnNull&&i===null)&&!(!this.options.returnEmptyString&&i==="")}},{key:"getResource",value:function(i,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(i,s,o,a):this.resourceStore.getResource(i,s,o,a)}}],[{key:"hasDefaultValue",value:function(i){var s="defaultValue";for(var o in i)if(Object.prototype.hasOwnProperty.call(i,o)&&s===o.substring(0,s.length)&&i[o]!==void 0)return!0;return!1}}]),t}(QA);function pB(n){return n.charAt(0).toUpperCase()+n.slice(1)}var uP=function(){function n(e){Xs(this,n),this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=na.create("languageUtils")}return Zs(n,[{key:"getScriptPartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return null;var r=t.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}},{key:"getLanguagePartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return t;var r=t.split("-");return this.formatLanguageCode(r[0])}},{key:"formatLanguageCode",value:function(t){if(typeof t=="string"&&t.indexOf("-")>-1){var r=["hans","hant","latn","cyrl","cans","mong","arab"],i=t.split("-");return this.options.lowerCaseLng?i=i.map(function(s){return s.toLowerCase()}):i.length===2?(i[0]=i[0].toLowerCase(),i[1]=i[1].toUpperCase(),r.indexOf(i[1].toLowerCase())>-1&&(i[1]=pB(i[1].toLowerCase()))):i.length===3&&(i[0]=i[0].toLowerCase(),i[1].length===2&&(i[1]=i[1].toUpperCase()),i[0]!=="sgn"&&i[2].length===2&&(i[2]=i[2].toUpperCase()),r.indexOf(i[1].toLowerCase())>-1&&(i[1]=pB(i[1].toLowerCase())),r.indexOf(i[2].toLowerCase())>-1&&(i[2]=pB(i[2].toLowerCase()))),i.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}},{key:"isSupportedCode",value:function(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}},{key:"getBestMatchFromCodes",value:function(t){var r=this;if(!t)return null;var i;return t.forEach(function(s){if(!i){var o=r.formatLanguageCode(s);(!r.options.supportedLngs||r.isSupportedCode(o))&&(i=o)}}),!i&&this.options.supportedLngs&&t.forEach(function(s){if(!i){var o=r.getLanguagePartFromCode(s);if(r.isSupportedCode(o))return i=o;i=r.options.supportedLngs.find(function(a){if(a.indexOf(o)===0)return a})}}),i||(i=this.getFallbackCodes(this.options.fallbackLng)[0]),i}},{key:"getFallbackCodes",value:function(t,r){if(!t)return[];if(typeof t=="function"&&(t=t(r)),typeof t=="string"&&(t=[t]),Object.prototype.toString.apply(t)==="[object Array]")return t;if(!r)return t.default||[];var i=t[r];return i||(i=t[this.getScriptPartFromCode(r)]),i||(i=t[this.formatLanguageCode(r)]),i||(i=t[this.getLanguagePartFromCode(r)]),i||(i=t.default),i||[]}},{key:"toResolveHierarchy",value:function(t,r){var i=this,s=this.getFallbackCodes(r||this.options.fallbackLng||[],t),o=[],a=function(A){A&&(i.isSupportedCode(A)?o.push(A):i.logger.warn("rejecting language code not found in supportedLngs: ".concat(A)))};return typeof t=="string"&&t.indexOf("-")>-1?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):typeof t=="string"&&a(this.formatLanguageCode(t)),s.forEach(function(l){o.indexOf(l)<0&&a(i.formatLanguageCode(l))}),o}}]),n}(),jhe=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Whe={1:function(e){return+(e>1)},2:function(e){return+(e!=1)},3:function(e){return 0},4:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},5:function(e){return e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5},6:function(e){return e==1?0:e>=2&&e<=4?1:2},7:function(e){return e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},8:function(e){return e==1?0:e==2?1:e!=8&&e!=11?2:3},9:function(e){return+(e>=2)},10:function(e){return e==1?0:e==2?1:e<7?2:e<11?3:4},11:function(e){return e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3},12:function(e){return+(e%10!=1||e%100==11)},13:function(e){return+(e!==0)},14:function(e){return e==1?0:e==2?1:e==3?2:3},15:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2},16:function(e){return e%10==1&&e%100!=11?0:e!==0?1:2},17:function(e){return e==1||e%10==1&&e%100!=11?0:1},18:function(e){return e==0?0:e==1?1:2},19:function(e){return e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3},20:function(e){return e==1?0:e==0||e%100>0&&e%100<20?1:2},21:function(e){return e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0},22:function(e){return e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3}},Khe=["v1","v2","v3"],fP={zero:0,one:1,two:2,few:3,many:4,other:5};function $he(){var n={};return jhe.forEach(function(e){e.lngs.forEach(function(t){n[t]={numbers:e.nr,plurals:Whe[e.fc]}})}),n}var Yhe=function(){function n(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Xs(this,n),this.languageUtils=e,this.options=t,this.logger=na.create("pluralResolver"),(!this.options.compatibilityJSON||this.options.compatibilityJSON==="v4")&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=$he()}return Zs(n,[{key:"addRule",value:function(t,r){this.rules[t]=r}},{key:"getRule",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(t,{type:r.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}},{key:"needsPlural",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=this.getRule(t,r);return this.shouldUseIntlApi()?i&&i.resolvedOptions().pluralCategories.length>1:i&&i.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(t,r){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,i).map(function(s){return"".concat(r).concat(s)})}},{key:"getSuffixes",value:function(t){var r=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=this.getRule(t,i);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(function(o,a){return fP[o]-fP[a]}).map(function(o){return"".concat(r.options.prepend).concat(o)}):s.numbers.map(function(o){return r.getSuffix(t,o,i)}):[]}},{key:"getSuffix",value:function(t,r){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=this.getRule(t,i);return s?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(s.select(r)):this.getSuffixRetroCompatible(s,r):(this.logger.warn("no plural rule found for: ".concat(t)),"")}},{key:"getSuffixRetroCompatible",value:function(t,r){var i=this,s=t.noAbs?t.plurals(r):t.plurals(Math.abs(r)),o=t.numbers[s];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(o===2?o="plural":o===1&&(o=""));var a=function(){return i.options.prepend&&o.toString()?i.options.prepend+o.toString():o.toString()};return this.options.compatibilityJSON==="v1"?o===1?"":typeof o=="number"?"_plural_".concat(o.toString()):a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}},{key:"shouldUseIntlApi",value:function(){return!Khe.includes(this.options.compatibilityJSON)}}]),n}();function hP(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Ao(n){for(var e=1;e0&&arguments[0]!==void 0?arguments[0]:{};Xs(this,n),this.logger=na.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||function(t){return t},this.init(e)}return Zs(n,[{key:"init",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});var r=t.interpolation;this.escape=r.escape!==void 0?r.escape:Ohe,this.escapeValue=r.escapeValue!==void 0?r.escapeValue:!0,this.useRawValueToEscape=r.useRawValueToEscape!==void 0?r.useRawValueToEscape:!1,this.prefix=r.prefix?Zu(r.prefix):r.prefixEscaped||"{{",this.suffix=r.suffix?Zu(r.suffix):r.suffixEscaped||"}}",this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||",",this.unescapePrefix=r.unescapeSuffix?"":r.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":r.unescapeSuffix||"",this.nestingPrefix=r.nestingPrefix?Zu(r.nestingPrefix):r.nestingPrefixEscaped||Zu("$t("),this.nestingSuffix=r.nestingSuffix?Zu(r.nestingSuffix):r.nestingSuffixEscaped||Zu(")"),this.nestingOptionsSeparator=r.nestingOptionsSeparator?r.nestingOptionsSeparator:r.nestingOptionsSeparator||",",this.maxReplaces=r.maxReplaces?r.maxReplaces:1e3,this.alwaysFormat=r.alwaysFormat!==void 0?r.alwaysFormat:!1,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var t="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(t,"g");var r="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(r,"g");var i="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(i,"g")}},{key:"interpolate",value:function(t,r,i,s){var o=this,a,l,A,c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function u(g){return g.replace(/\$/g,"$$$$")}var f=function(m){if(m.indexOf(o.formatSeparator)<0){var y=oP(r,c,m);return o.alwaysFormat?o.format(y,void 0,i,Ao(Ao(Ao({},s),r),{},{interpolationkey:m})):y}var w=m.split(o.formatSeparator),x=w.shift().trim(),_=w.join(o.formatSeparator).trim();return o.format(oP(r,c,x),_,i,Ao(Ao(Ao({},s),r),{},{interpolationkey:x}))};this.resetRegExp();var h=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,p=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables,d=[{regex:this.regexpUnescape,safeValue:function(m){return u(m)}},{regex:this.regexp,safeValue:function(m){return o.escapeValue?u(o.escape(m)):u(m)}}];return d.forEach(function(g){for(A=0;a=g.regex.exec(t);){var m=a[1].trim();if(l=f(m),l===void 0)if(typeof h=="function"){var y=h(t,a,s);l=typeof y=="string"?y:""}else if(s&&Object.prototype.hasOwnProperty.call(s,m))l="";else if(p){l=a[0];continue}else o.logger.warn("missed to pass in variable ".concat(m," for interpolating ").concat(t)),l="";else typeof l!="string"&&!o.useRawValueToEscape&&(l=iP(l));var w=g.safeValue(l);if(t=t.replace(a[0],w),p?(g.regex.lastIndex+=l.length,g.regex.lastIndex-=a[0].length):g.regex.lastIndex=0,A++,A>=o.maxReplaces)break}}),t}},{key:"nest",value:function(t,r){var i=this,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o,a,l;function A(h,p){var d=this.nestingOptionsSeparator;if(h.indexOf(d)<0)return h;var g=h.split(new RegExp("".concat(d,"[ ]*{"))),m="{".concat(g[1]);h=g[0],m=this.interpolate(m,l);var y=m.match(/'/g),w=m.match(/"/g);(y&&y.length%2===0&&!w||w.length%2!==0)&&(m=m.replace(/'/g,'"'));try{l=JSON.parse(m),p&&(l=Ao(Ao({},p),l))}catch(x){return this.logger.warn("failed parsing options string in nesting for key ".concat(h),x),"".concat(h).concat(d).concat(m)}return delete l.defaultValue,h}for(;o=this.nestingRegexp.exec(t);){var c=[];l=Ao({},s),l=l.replace&&typeof l.replace!="string"?l.replace:l,l.applyPostProcessor=!1,delete l.defaultValue;var u=!1;if(o[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(o[1])){var f=o[1].split(this.formatSeparator).map(function(h){return h.trim()});o[1]=f.shift(),c=f,u=!0}if(a=r(A.call(this,o[1].trim(),l),l),a&&o[0]===t&&typeof a!="string")return a;typeof a!="string"&&(a=iP(a)),a||(this.logger.warn("missed to resolve ".concat(o[1]," for nesting ").concat(t)),a=""),u&&(a=c.reduce(function(h,p){return i.format(h,p,s.lng,Ao(Ao({},s),{},{interpolationkey:o[1].trim()}))},a.trim())),t=t.replace(o[0],a),this.regexp.lastIndex=0}return t}}]),n}();function dP(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Ha(n){for(var e=1;e-1){var r=n.split("(");e=r[0].toLowerCase().trim();var i=r[1].substring(0,r[1].length-1);if(e==="currency"&&i.indexOf(":")<0)t.currency||(t.currency=i.trim());else if(e==="relativetime"&&i.indexOf(":")<0)t.range||(t.range=i.trim());else{var s=i.split(";");s.forEach(function(o){if(o){var a=o.split(":"),l=Rhe(a),A=l[0],c=l.slice(1),u=c.join(":").trim().replace(/^'+|'+$/g,"");t[A.trim()]||(t[A.trim()]=u),u==="false"&&(t[A.trim()]=!1),u==="true"&&(t[A.trim()]=!0),isNaN(u)||(t[A.trim()]=parseInt(u,10))}})}}return{formatName:e,formatOptions:t}}function Ju(n){var e={};return function(r,i,s){var o=i+JSON.stringify(s),a=e[o];return a||(a=n(i,s),e[o]=a),a(r)}}var Jhe=function(){function n(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Xs(this,n),this.logger=na.create("formatter"),this.options=e,this.formats={number:Ju(function(t,r){var i=new Intl.NumberFormat(t,Ha({},r));return function(s){return i.format(s)}}),currency:Ju(function(t,r){var i=new Intl.NumberFormat(t,Ha(Ha({},r),{},{style:"currency"}));return function(s){return i.format(s)}}),datetime:Ju(function(t,r){var i=new Intl.DateTimeFormat(t,Ha({},r));return function(s){return i.format(s)}}),relativetime:Ju(function(t,r){var i=new Intl.RelativeTimeFormat(t,Ha({},r));return function(s){return i.format(s,r.range||"day")}}),list:Ju(function(t,r){var i=new Intl.ListFormat(t,Ha({},r));return function(s){return i.format(s)}})},this.init(e)}return Zs(n,[{key:"init",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}},i=r.interpolation;this.formatSeparator=i.formatSeparator?i.formatSeparator:i.formatSeparator||","}},{key:"add",value:function(t,r){this.formats[t.toLowerCase().trim()]=r}},{key:"addCached",value:function(t,r){this.formats[t.toLowerCase().trim()]=Ju(r)}},{key:"format",value:function(t,r,i){var s=this,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=r.split(this.formatSeparator),l=a.reduce(function(A,c){var u=Zhe(c),f=u.formatName,h=u.formatOptions;if(s.formats[f]){var p=A;try{var d=o&&o.formatParams&&o.formatParams[o.interpolationkey]||{},g=d.locale||d.lng||o.locale||o.lng||i;p=s.formats[f](A,g,Ha(Ha(Ha({},h),o),d))}catch(m){s.logger.warn(m)}return p}else s.logger.warn("there was no format function for ".concat(f));return A},t);return l}}]),n}();function pP(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function mP(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function tde(n,e){n.pending[e]!==void 0&&(delete n.pending[e],n.pendingCount--)}var nde=function(n){s_(t,n);var e=qhe(t);function t(r,i,s){var o,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return Xs(this,t),o=e.call(this),o_&&QA.call(IA(o)),o.backend=r,o.store=i,o.services=s,o.languageUtils=s.languageUtils,o.options=a,o.logger=na.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=a.maxParallelReads||10,o.readingCalls=0,o.maxRetries=a.maxRetries>=0?a.maxRetries:5,o.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(s,a.backend,a),o}return Zs(t,[{key:"queueLoad",value:function(i,s,o,a){var l=this,A={},c={},u={},f={};return i.forEach(function(h){var p=!0;s.forEach(function(d){var g="".concat(h,"|").concat(d);!o.reload&&l.store.hasResourceBundle(h,d)?l.state[g]=2:l.state[g]<0||(l.state[g]===1?c[g]===void 0&&(c[g]=!0):(l.state[g]=1,p=!1,c[g]===void 0&&(c[g]=!0),A[g]===void 0&&(A[g]=!0),f[d]===void 0&&(f[d]=!0)))}),p||(u[h]=!0)}),(Object.keys(A).length||Object.keys(c).length)&&this.queue.push({pending:c,pendingCount:Object.keys(c).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(A),pending:Object.keys(c),toLoadLanguages:Object.keys(u),toLoadNamespaces:Object.keys(f)}}},{key:"loaded",value:function(i,s,o){var a=i.split("|"),l=a[0],A=a[1];s&&this.emit("failedLoading",l,A,s),o&&this.store.addResourceBundle(l,A,o),this.state[i]=s?-1:2;var c={};this.queue.forEach(function(u){Phe(u.loaded,[l],A),tde(u,i),s&&u.errors.push(s),u.pendingCount===0&&!u.done&&(Object.keys(u.loaded).forEach(function(f){c[f]||(c[f]={});var h=u.loaded[f];h.length&&h.forEach(function(p){c[f][p]===void 0&&(c[f][p]=!0)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",c),this.queue=this.queue.filter(function(u){return!u.done})}},{key:"read",value:function(i,s,o){var a=this,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,A=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,c=arguments.length>5?arguments[5]:void 0;if(!i.length)return c(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:i,ns:s,fcName:o,tried:l,wait:A,callback:c});return}this.readingCalls++;var u=function(d,g){if(a.readingCalls--,a.waitingReads.length>0){var m=a.waitingReads.shift();a.read(m.lng,m.ns,m.fcName,m.tried,m.wait,m.callback)}if(d&&g&&l2&&arguments[2]!==void 0?arguments[2]:{},l=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),l&&l();typeof i=="string"&&(i=this.languageUtils.toResolveHierarchy(i)),typeof s=="string"&&(s=[s]);var A=this.queueLoad(i,s,a,l);if(!A.toLoad.length)return A.pending.length||l(),null;A.toLoad.forEach(function(c){o.loadOne(c)})}},{key:"load",value:function(i,s,o){this.prepareLoading(i,s,{},o)}},{key:"reload",value:function(i,s,o){this.prepareLoading(i,s,{reload:!0},o)}},{key:"loadOne",value:function(i){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",a=i.split("|"),l=a[0],A=a[1];this.read(l,A,"read",void 0,void 0,function(c,u){c&&s.logger.warn("".concat(o,"loading namespace ").concat(A," for language ").concat(l," failed"),c),!c&&u&&s.logger.log("".concat(o,"loaded namespace ").concat(A," for language ").concat(l),u),s.loaded(i,c,u)})}},{key:"saveMissing",value:function(i,s,o,a,l){var A=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},c=arguments.length>6&&arguments[6]!==void 0?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(s)){this.logger.warn('did not save key "'.concat(o,'" as the namespace "').concat(s,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(o==null||o==="")){if(this.backend&&this.backend.create){var u=mP(mP({},A),{},{isUpdate:l}),f=this.backend.create.bind(this.backend);if(f.length<6)try{var h;f.length===5?h=f(i,s,o,a,u):h=f(i,s,o,a),h&&typeof h.then=="function"?h.then(function(p){return c(null,p)}).catch(c):c(null,h)}catch(p){c(p)}else f(i,s,o,a,c,u)}!i||!i[0]||this.store.addResource(i[0],s,o,a)}}}]),t}(QA);function gP(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if(ks(e[1])==="object"&&(t=e[1]),typeof e[1]=="string"&&(t.defaultValue=e[1]),typeof e[2]=="string"&&(t.tDescription=e[2]),ks(e[2])==="object"||ks(e[3])==="object"){var r=e[3]||e[2];Object.keys(r).forEach(function(i){t[i]=r[i]})}return t},interpolation:{escapeValue:!0,format:function(e,t,r,i){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function vP(n){return typeof n.ns=="string"&&(n.ns=[n.ns]),typeof n.fallbackLng=="string"&&(n.fallbackLng=[n.fallbackLng]),typeof n.fallbackNS=="string"&&(n.fallbackNS=[n.fallbackNS]),n.supportedLngs&&n.supportedLngs.indexOf("cimode")<0&&(n.supportedLngs=n.supportedLngs.concat(["cimode"])),n}function yP(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function Oo(n){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function bv(){}function sde(n){var e=Object.getOwnPropertyNames(Object.getPrototypeOf(n));e.forEach(function(t){typeof n[t]=="function"&&(n[t]=n[t].bind(n))})}var Vw=function(n){s_(t,n);var e=rde(t);function t(){var r,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(Xs(this,t),r=e.call(this),o_&&QA.call(IA(r)),r.options=vP(i),r.services={},r.logger=na,r.modules={external:[]},sde(IA(r)),s&&!r.isInitialized&&!i.isClone){if(!r.options.initImmediate)return r.init(i,s),Eg(r,IA(r));setTimeout(function(){r.init(i,s)},0)}return r}return Zs(t,[{key:"init",value:function(){var i=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;typeof s=="function"&&(o=s,s={}),!s.defaultNS&&s.defaultNS!==!1&&s.ns&&(typeof s.ns=="string"?s.defaultNS=s.ns:s.ns.indexOf("translation")<0&&(s.defaultNS=s.ns[0]));var a=gP();this.options=Oo(Oo(Oo({},a),this.options),vP(s)),this.options.compatibilityAPI!=="v1"&&(this.options.interpolation=Oo(Oo({},a.interpolation),this.options.interpolation)),s.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=s.keySeparator),s.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=s.nsSeparator);function l(m){return m?typeof m=="function"?new m:m:null}if(!this.options.isClone){this.modules.logger?na.init(l(this.modules.logger),this.options):na.init(null,this.options);var A;this.modules.formatter?A=this.modules.formatter:typeof Intl<"u"&&(A=Jhe);var c=new uP(this.options);this.store=new zhe(this.options.resources,this.options);var u=this.services;u.logger=na,u.resourceStore=this.store,u.languageUtils=c,u.pluralResolver=new Yhe(c,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),A&&(!this.options.interpolation.format||this.options.interpolation.format===a.interpolation.format)&&(u.formatter=l(A),u.formatter.init(u,this.options),this.options.interpolation.format=u.formatter.format.bind(u.formatter)),u.interpolator=new Xhe(this.options),u.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},u.backendConnector=new nde(l(this.modules.backend),u.resourceStore,u,this.options),u.backendConnector.on("*",function(m){for(var y=arguments.length,w=new Array(y>1?y-1:0),x=1;x1?y-1:0),x=1;x0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined");var h=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];h.forEach(function(m){i[m]=function(){var y;return(y=i.store)[m].apply(y,arguments)}});var p=["addResource","addResources","addResourceBundle","removeResourceBundle"];p.forEach(function(m){i[m]=function(){var y;return(y=i.store)[m].apply(y,arguments),i}});var d=op(),g=function(){var y=function(x,_){i.isInitialized&&!i.initializedStoreOnce&&i.logger.warn("init: i18next is already initialized. You should call init just once!"),i.isInitialized=!0,i.options.isClone||i.logger.log("initialized",i.options),i.emit("initialized",i.options),d.resolve(_),o(x,_)};if(i.languages&&i.options.compatibilityAPI!=="v1"&&!i.isInitialized)return y(null,i.t.bind(i));i.changeLanguage(i.options.lng,y)};return this.options.resources||!this.options.initImmediate?g():setTimeout(g,0),d}},{key:"loadResources",value:function(i){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:bv,a=o,l=typeof i=="string"?i:this.language;if(typeof i=="function"&&(a=i),!this.options.resources||this.options.partialBundledLanguages){if(l&&l.toLowerCase()==="cimode")return a();var A=[],c=function(h){if(h){var p=s.services.languageUtils.toResolveHierarchy(h);p.forEach(function(d){A.indexOf(d)<0&&A.push(d)})}};if(l)c(l);else{var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.forEach(function(f){return c(f)})}this.options.preload&&this.options.preload.forEach(function(f){return c(f)}),this.services.backendConnector.load(A,this.options.ns,function(f){!f&&!s.resolvedLanguage&&s.language&&s.setResolvedLanguage(s.language),a(f)})}else a(null)}},{key:"reloadResources",value:function(i,s,o){var a=op();return i||(i=this.languages),s||(s=this.options.ns),o||(o=bv),this.services.backendConnector.reload(i,s,function(l){a.resolve(),o(l)}),a}},{key:"use",value:function(i){if(!i)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!i.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return i.type==="backend"&&(this.modules.backend=i),(i.type==="logger"||i.log&&i.warn&&i.error)&&(this.modules.logger=i),i.type==="languageDetector"&&(this.modules.languageDetector=i),i.type==="i18nFormat"&&(this.modules.i18nFormat=i),i.type==="postProcessor"&&z5.addPostProcessor(i),i.type==="formatter"&&(this.modules.formatter=i),i.type==="3rdParty"&&this.modules.external.push(i),this}},{key:"setResolvedLanguage",value:function(i){if(!(!i||!this.languages)&&!(["cimode","dev"].indexOf(i)>-1))for(var s=0;s-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}}},{key:"changeLanguage",value:function(i,s){var o=this;this.isLanguageChangingTo=i;var a=op();this.emit("languageChanging",i);var l=function(f){o.language=f,o.languages=o.services.languageUtils.toResolveHierarchy(f),o.resolvedLanguage=void 0,o.setResolvedLanguage(f)},A=function(f,h){h?(l(h),o.translator.changeLanguage(h),o.isLanguageChangingTo=void 0,o.emit("languageChanged",h),o.logger.log("languageChanged",h)):o.isLanguageChangingTo=void 0,a.resolve(function(){return o.t.apply(o,arguments)}),s&&s(f,function(){return o.t.apply(o,arguments)})},c=function(f){!i&&!f&&o.services.languageDetector&&(f=[]);var h=typeof f=="string"?f:o.services.languageUtils.getBestMatchFromCodes(f);h&&(o.language||l(h),o.translator.language||o.translator.changeLanguage(h),o.services.languageDetector&&o.services.languageDetector.cacheUserLanguage&&o.services.languageDetector.cacheUserLanguage(h)),o.loadResources(h,function(p){A(p,h)})};return!i&&this.services.languageDetector&&!this.services.languageDetector.async?c(this.services.languageDetector.detect()):!i&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(c):this.services.languageDetector.detect(c):c(i),a}},{key:"getFixedT",value:function(i,s,o){var a=this,l=function A(c,u){var f;if(ks(u)!=="object"){for(var h=arguments.length,p=new Array(h>2?h-2:0),d=2;d1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var a=this.resolvedLanguage||this.languages[0],l=this.options?this.options.fallbackLng:!1,A=this.languages[this.languages.length-1];if(a.toLowerCase()==="cimode")return!0;var c=function(h,p){var d=s.services.backendConnector.state["".concat(h,"|").concat(p)];return d===-1||d===2};if(o.precheck){var u=o.precheck(this,c);if(u!==void 0)return u}return!!(this.hasResourceBundle(a,i)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||c(a,i)&&(!l||c(A,i)))}},{key:"loadNamespaces",value:function(i,s){var o=this,a=op();return this.options.ns?(typeof i=="string"&&(i=[i]),i.forEach(function(l){o.options.ns.indexOf(l)<0&&o.options.ns.push(l)}),this.loadResources(function(l){a.resolve(),s&&s(l)}),a):(s&&s(),Promise.resolve())}},{key:"loadLanguages",value:function(i,s){var o=op();typeof i=="string"&&(i=[i]);var a=this.options.preload||[],l=i.filter(function(A){return a.indexOf(A)<0});return l.length?(this.options.preload=a.concat(l),this.loadResources(function(A){o.resolve(),s&&s(A)}),o):(s&&s(),Promise.resolve())}},{key:"dir",value:function(i){if(i||(i=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!i)return"rtl";var s=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],o=this.services&&this.services.languageUtils||new uP(gP());return s.indexOf(o.getLanguagePartFromCode(i))>-1||i.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var i=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:bv,a=Oo(Oo(Oo({},this.options),s),{isClone:!0}),l=new t(a);(s.debug!==void 0||s.prefix!==void 0)&&(l.logger=l.logger.clone(s));var A=["store","services","language"];return A.forEach(function(c){l[c]=i[c]}),l.services=Oo({},this.services),l.services.utils={hasLoadedNamespace:l.hasLoadedNamespace.bind(l)},l.translator=new cP(l.services,l.options),l.translator.on("*",function(c){for(var u=arguments.length,f=new Array(u>1?u-1:0),h=1;h0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;return new Vw(n,e)});var qr=Vw.createInstance();qr.createInstance=Vw.createInstance;qr.createInstance;qr.dir;qr.init;qr.loadResources;qr.reloadResources;qr.use;qr.changeLanguage;qr.getFixedT;qr.t;qr.exists;qr.setDefaultNamespace;qr.hasLoadedNamespace;qr.loadNamespaces;qr.loadLanguages;function ode(){if(console&&console.warn){for(var n,e=arguments.length,t=new Array(e),r=0;r2&&arguments[2]!==void 0?arguments[2]:{},r=e.languages[0],i=e.options?e.options.fallbackLng:!1,s=e.languages[e.languages.length-1];if(r.toLowerCase()==="cimode")return!0;var o=function(l,A){var c=e.services.backendConnector.state["".concat(l,"|").concat(A)];return c===-1||c===2};return t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&e.services.backendConnector.backend&&e.isLanguageChangingTo&&!o(e.isLanguageChangingTo,n)?!1:!!(e.hasResourceBundle(r,n)||!e.services.backendConnector.backend||e.options.resources&&!e.options.partialBundledLanguages||o(r,n)&&(!i||o(s,n)))}function lde(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!e.languages||!e.languages.length)return JC("i18n.languages were undefined or empty",e.languages),!0;var r=e.options.ignoreJSONStructure!==void 0;return r?e.hasLoadedNamespace(n,{precheck:function(s,o){if(t.bindI18n&&t.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!o(s.isLanguageChangingTo,n))return!1}}):ade(n,e,t)}var Ade=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,cde={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},ude=function(e){return cde[e]},fde=function(e){return e.replace(Ade,ude)};function _P(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function bP(n){for(var e=1;e0&&arguments[0]!==void 0?arguments[0]:{};qC=bP(bP({},qC),n)}function dde(){return qC}var G5;function pde(n){G5=n}function mde(){return G5}var gde={type:"3rdParty",init:function(e){hde(e.options.react),pde(e)}},vde=ye.createContext(),yde=function(){function n(){Xs(this,n),this.usedNamespaces={}}return Zs(n,[{key:"addUsedNamespaces",value:function(t){var r=this;t.forEach(function(i){r.usedNamespaces[i]||(r.usedNamespaces[i]=!0)})}},{key:"getUsedNamespaces",value:function(){return Object.keys(this.usedNamespaces)}}]),n}();function wde(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var r,i,s,o,a=[],l=!0,A=!1;try{if(s=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(r=s.call(t)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(c){A=!0,i=c}finally{try{if(!l&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(A)throw i}}return a}}function xde(n,e){return O5(n)||wde(n,e)||N5(n,e)||k5()}function BP(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,r)}return t}function mB(n){for(var e=1;e1&&arguments[1]!==void 0?arguments[1]:{},t=e.i18n,r=ye.useContext(vde)||{},i=r.i18n,s=r.defaultNS,o=t||i||mde();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new yde),!o){JC("You will need to pass in an i18next instance by using initReactI18next");var a=function(M,D){return typeof D=="string"?D:D&&ks(D)==="object"&&typeof D.defaultValue=="string"?D.defaultValue:Array.isArray(M)?M[M.length-1]:M},l=[a,{},!1];return l.t=a,l.i18n={},l.ready=!1,l}o.options.react&&o.options.react.wait!==void 0&&JC("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");var A=mB(mB(mB({},dde()),o.options.react),e),c=A.useSuspense,u=A.keyPrefix,f=n||s||o.options&&o.options.defaultNS;f=typeof f=="string"?[f]:f||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(f);var h=(o.isInitialized||o.initializedStoreOnce)&&f.every(function(b){return lde(b,o,A)});function p(){return o.getFixedT(null,A.nsMode==="fallback"?f:f[0],u)}var d=ye.useState(p),g=xde(d,2),m=g[0],y=g[1],w=f.join(),x=_de(w),_=ye.useRef(!0);ye.useEffect(function(){var b=A.bindI18n,M=A.bindI18nStore;_.current=!0,!h&&!c&&xP(o,f,function(){_.current&&y(p)}),h&&x&&x!==w&&_.current&&y(p);function D(){_.current&&y(p)}return b&&o&&o.on(b,D),M&&o&&o.store.on(M,D),function(){_.current=!1,b&&o&&b.split(" ").forEach(function($){return o.off($,D)}),M&&o&&M.split(" ").forEach(function($){return o.store.off($,D)})}},[o,w]);var C=ye.useRef(!0);ye.useEffect(function(){_.current&&!C.current&&y(p),C.current=!1},[o,u]);var S=[m,o,h];if(S.t=m,S.i18n=o,S.ready=h,h||!h&&!c)return S;throw new Promise(function(b){xP(o,f,function(){b()})})}var V5=[],Bde=V5.forEach,Ede=V5.slice;function Cde(n){return Bde.call(Ede.call(arguments,1),function(e){if(e)for(var t in e)n[t]===void 0&&(n[t]=e[t])}),n}var EP=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Sde=function(e,t,r){var i=r||{};i.path=i.path||"/";var s=encodeURIComponent(t),o="".concat(e,"=").concat(s);if(i.maxAge>0){var a=i.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");o+="; Max-Age=".concat(Math.floor(a))}if(i.domain){if(!EP.test(i.domain))throw new TypeError("option domain is invalid");o+="; Domain=".concat(i.domain)}if(i.path){if(!EP.test(i.path))throw new TypeError("option path is invalid");o+="; Path=".concat(i.path)}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");o+="; Expires=".concat(i.expires.toUTCString())}if(i.httpOnly&&(o+="; HttpOnly"),i.secure&&(o+="; Secure"),i.sameSite){var l=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite;switch(l){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o},CP={create:function(e,t,r,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(s.expires=new Date,s.expires.setTime(s.expires.getTime()+r*60*1e3)),i&&(s.domain=i),document.cookie=Sde(e,encodeURIComponent(t),s)},read:function(e){for(var t="".concat(e,"="),r=document.cookie.split(";"),i=0;i-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var i=r.substring(1),s=i.split("&"),o=0;o0){var l=s[o].substring(0,a);l===e.lookupQuerystring&&(t=s[o].substring(a+1))}}}return t}},ap=null,SP=function(){if(ap!==null)return ap;try{ap=window!=="undefined"&&window.localStorage!==null;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch{ap=!1}return ap},Ide={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&SP()){var r=window.localStorage.getItem(e.lookupLocalStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&SP()&&window.localStorage.setItem(t.lookupLocalStorage,e)}},lp=null,MP=function(){if(lp!==null)return lp;try{lp=window!=="undefined"&&window.sessionStorage!==null;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch{lp=!1}return lp},Rde={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&MP()){var r=window.sessionStorage.getItem(e.lookupSessionStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&MP()&&window.sessionStorage.setItem(t.lookupSessionStorage,e)}},Fde={name:"navigator",lookup:function(e){var t=[];if(typeof navigator<"u"){if(navigator.languages)for(var r=0;r0?t:void 0}},Ude={name:"htmlTag",lookup:function(e){var t,r=e.htmlTag||(typeof document<"u"?document.documentElement:null);return r&&typeof r.getAttribute=="function"&&(t=r.getAttribute("lang")),t}},Lde={name:"path",lookup:function(e){var t;if(typeof window<"u"){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if(typeof e.lookupFromPathIndex=="number"){if(typeof r[e.lookupFromPathIndex]!="string")return;t=r[e.lookupFromPathIndex].replace("/","")}else t=r[0].replace("/","")}return t}},Pde={name:"subdomain",lookup:function(e){var t=typeof e.lookupFromSubdomainIndex=="number"?e.lookupFromSubdomainIndex+1:1,r=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[t]}};function Dde(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"]}}var j5=function(){function n(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Xs(this,n),this.type="languageDetector",this.detectors={},this.init(e,t)}return Zs(n,[{key:"init",value:function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=t,this.options=Cde(r,this.options||{},Dde()),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(Mde),this.addDetector(Tde),this.addDetector(Ide),this.addDetector(Rde),this.addDetector(Fde),this.addDetector(Ude),this.addDetector(Lde),this.addDetector(Pde)}},{key:"addDetector",value:function(t){this.detectors[t.name]=t}},{key:"detect",value:function(t){var r=this;t||(t=this.options.order);var i=[];return t.forEach(function(s){if(r.detectors[s]){var o=r.detectors[s].lookup(r.options);o&&typeof o=="string"&&(o=[o]),o&&(i=i.concat(o))}}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(t,r){var i=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||r.forEach(function(s){i.detectors[s]&&i.detectors[s].cacheUserLanguage(t,i.options)}))}}]),n}();j5.type="languageDetector";const Ode={translation:{pageTitles:{chooseClass:"Choose Character Class",chooseAppearance:"Choose Appearance",saveCharacter:"Save Your Character"},callToAction:{next:"Next",back:"Back",randomize:"Randomize",send:"Send"},editor:{title:"Appearance",head:"Head",body:"Body",eyes:"Eyes",outer:"Outer",chest:"Chest",legs:"Legs",feet:"Feet",accessories:"Accessories"},labels:{name:"Name",voice:"Voice",favoriteColor:"Favorite Color",preferredGreeting:"Preferred Greeting",question:"Question",yourName:"Your Name",conversation:"Conversation"},text:{unoptimized:"Unoptimized",apiUnderMaintnance:"Voice generation API is temporarily disabled for maintenance!"}}},Nde={translation:{pageTitles:{chooseClass:"Выбрать Класс Персонажа",chooseAppearance:"Выбрать Внешность",saveCharacter:"Сохранить Персонажа"},callToAction:{next:"Далее",back:"Назад",randomize:"Рандомизировать",send:"Отправить"},editor:{title:"Внешность",head:"Голова",body:"Тело",eyes:"Глаза",outer:"Внешний",chest:"Грудь",legs:"Ноги",feet:"Стопы",accessories:"Аксессуары"},labels:{name:"Имя",voice:"Голос",favoriteColor:"Любимый Цвет",preferredGreeting:"Предпочитаемое Приветствие",question:"Вопрос",yourName:"Ваше Имя",conversation:"Разговор"},text:{unoptimized:"Неоптимизи­рованный",apiUnderMaintnance:"API генерации голоса временно отключен на техническое обслуживание."}}},kde={translation:{pageTitles:{chooseClass:"选择角色类型",chooseAppearance:"选择外观",saveCharacter:"保存角色"},callToAction:{next:"下一步",back:"返回",randomize:"随机",send:"发送"},editor:{title:"外观",head:"头部",body:"身体",eyes:"眼睛",outer:"外套",chest:"上身",legs:"腿部",feet:"脚部",accessories:"配件"},labels:{name:"名字",voice:"语音",favoriteColor:"颜色偏好",preferredGreeting:"首选问候语",question:"问题",yourName:"你的名字",conversation:"对话"},text:{unoptimized:"未优化",apiUnderMaintnance:"语音生成API暂时关闭进行维护!"}}},Qde={en:Ode,ru:Nde,zh:kde};qr.use(j5).use(gde).init({debug:!0,fallbackLng:"en",interpolation:{escapeValue:!1},resources:Qde});const To=ye.createContext(),Hde=n=>{const{t:e}=bde();return k.jsx(To.Provider,{value:{t:e},children:n.children})},zde=` uniform vec3 cameraDir; uniform vec3 eye; diff --git a/index.html b/index.html index e93e69aa..4d37aa1b 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ Character Studio - +