@tscircuit/runframe 0.0.1421 → 0.0.1422
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4036,7 +4036,7 @@ void main() {
|
|
|
4036
4036
|
|
|
4037
4037
|
}
|
|
4038
4038
|
|
|
4039
|
-
}`;class vDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(A,e,i){if(this.texture===null){const o=new Yc,n=A.properties.get(o);n.__webglTexture=e.texture,(e.depthNear!=i.depthNear||e.depthFar!=i.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=o}}getMesh(A){if(this.texture!==null&&this.mesh===null){const e=A.cameras[0].viewport,i=new Aw({vertexShader:NDe,fragmentShader:MDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new on(new im(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}}class UDe extends Mk{constructor(A,e){super();const i=this;let o=null,n=1,s=null,r="local-floor",a=1,g=null,I=null,c=null,B=null,C=null,l=null;const Q=new vDe,E=e.getContextAttributes();let h=null,u=null;const d=[],f=[],D=new Io;let w=null;const x=new sE;x.layers.enable(1),x.viewport=new ug;const b=new sE;b.layers.enable(2),b.viewport=new ug;const F=[x,b],k=new _De;k.layers.enable(1),k.layers.enable(2);let U=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(pA){let bA=d[pA];return bA===void 0&&(bA=new tz,d[pA]=bA),bA.getTargetRaySpace()},this.getControllerGrip=function(pA){let bA=d[pA];return bA===void 0&&(bA=new tz,d[pA]=bA),bA.getGripSpace()},this.getHand=function(pA){let bA=d[pA];return bA===void 0&&(bA=new tz,d[pA]=bA),bA.getHandSpace()};function J(pA){const bA=f.indexOf(pA.inputSource);if(bA===-1)return;const vA=d[bA];vA!==void 0&&(vA.update(pA.inputSource,pA.frame,g||s),vA.dispatchEvent({type:pA.type,data:pA.inputSource}))}function P(){o.removeEventListener("select",J),o.removeEventListener("selectstart",J),o.removeEventListener("selectend",J),o.removeEventListener("squeeze",J),o.removeEventListener("squeezestart",J),o.removeEventListener("squeezeend",J),o.removeEventListener("end",P),o.removeEventListener("inputsourceschange",T);for(let pA=0;pA<d.length;pA++){const bA=f[pA];bA!==null&&(f[pA]=null,d[pA].disconnect(bA))}U=null,N=null,Q.reset(),A.setRenderTarget(h),C=null,B=null,c=null,o=null,u=null,gA.stop(),i.isPresenting=!1,A.setPixelRatio(w),A.setSize(D.width,D.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(pA){n=pA,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(pA){r=pA,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return g||s},this.setReferenceSpace=function(pA){g=pA},this.getBaseLayer=function(){return B!==null?B:C},this.getBinding=function(){return c},this.getFrame=function(){return l},this.getSession=function(){return o},this.setSession=async function(pA){if(o=pA,o!==null){if(h=A.getRenderTarget(),o.addEventListener("select",J),o.addEventListener("selectstart",J),o.addEventListener("selectend",J),o.addEventListener("squeeze",J),o.addEventListener("squeezestart",J),o.addEventListener("squeezeend",J),o.addEventListener("end",P),o.addEventListener("inputsourceschange",T),E.xrCompatible!==!0&&await e.makeXRCompatible(),w=A.getPixelRatio(),A.getSize(D),o.renderState.layers===void 0){const bA={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:n};C=new XRWebGLLayer(o,e,bA),o.updateRenderState({baseLayer:C}),A.setPixelRatio(1),A.setSize(C.framebufferWidth,C.framebufferHeight,!1),u=new vk(C.framebufferWidth,C.framebufferHeight,{format:Z0,type:Qb,colorSpace:A.outputColorSpace,stencilBuffer:E.stencil})}else{let bA=null,vA=null,MA=null;E.depth&&(MA=E.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,bA=E.stencil?m_:y_,vA=E.stencil?f_:p_);const qA={colorFormat:e.RGBA8,depthFormat:MA,scaleFactor:n};c=new XRWebGLBinding(o,e),B=c.createProjectionLayer(qA),o.updateRenderState({layers:[B]}),A.setPixelRatio(1),A.setSize(B.textureWidth,B.textureHeight,!1),u=new vk(B.textureWidth,B.textureHeight,{format:Z0,type:Qb,depthTexture:new PSA(B.textureWidth,B.textureHeight,vA,void 0,void 0,void 0,void 0,void 0,void 0,bA),stencilBuffer:E.stencil,colorSpace:A.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:B.ignoreDepthValues===!1})}u.isXRRenderTarget=!0,this.setFoveation(a),g=null,s=await o.requestReferenceSpace(r),gA.setContext(o),gA.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(o!==null)return o.environmentBlendMode};function T(pA){for(let bA=0;bA<pA.removed.length;bA++){const vA=pA.removed[bA],MA=f.indexOf(vA);MA>=0&&(f[MA]=null,d[MA].disconnect(vA))}for(let bA=0;bA<pA.added.length;bA++){const vA=pA.added[bA];let MA=f.indexOf(vA);if(MA===-1){for(let CA=0;CA<d.length;CA++)if(CA>=f.length){f.push(vA),MA=CA;break}else if(f[CA]===null){f[CA]=vA,MA=CA;break}if(MA===-1)break}const qA=d[MA];qA&&qA.connect(vA)}}const O=new _e,W=new _e;function $(pA,bA,vA){O.setFromMatrixPosition(bA.matrixWorld),W.setFromMatrixPosition(vA.matrixWorld);const MA=O.distanceTo(W),qA=bA.projectionMatrix.elements,CA=vA.projectionMatrix.elements,mA=qA[14]/(qA[10]-1),uA=qA[14]/(qA[10]+1),PA=(qA[9]+1)/qA[5],ee=(qA[9]-1)/qA[5],Be=(qA[8]-1)/qA[0],yA=(CA[8]+1)/CA[0],WA=mA*Be,KA=mA*yA,JA=MA/(-Be+yA),jA=JA*-Be;bA.matrixWorld.decompose(pA.position,pA.quaternion,pA.scale),pA.translateX(jA),pA.translateZ(JA),pA.matrixWorld.compose(pA.position,pA.quaternion,pA.scale),pA.matrixWorldInverse.copy(pA.matrixWorld).invert();const GA=mA+JA,SA=uA+JA,_A=WA-jA,FA=KA+(MA-jA),TA=PA*uA/SA*GA,OA=ee*uA/SA*GA;pA.projectionMatrix.makePerspective(_A,FA,TA,OA,GA,SA),pA.projectionMatrixInverse.copy(pA.projectionMatrix).invert()}function oA(pA,bA){bA===null?pA.matrixWorld.copy(pA.matrix):pA.matrixWorld.multiplyMatrices(bA.matrixWorld,pA.matrix),pA.matrixWorldInverse.copy(pA.matrixWorld).invert()}this.updateCamera=function(pA){if(o===null)return;Q.texture!==null&&(pA.near=Q.depthNear,pA.far=Q.depthFar),k.near=b.near=x.near=pA.near,k.far=b.far=x.far=pA.far,(U!==k.near||N!==k.far)&&(o.updateRenderState({depthNear:k.near,depthFar:k.far}),U=k.near,N=k.far,x.near=U,x.far=N,b.near=U,b.far=N,x.updateProjectionMatrix(),b.updateProjectionMatrix(),pA.updateProjectionMatrix());const bA=pA.parent,vA=k.cameras;oA(k,bA);for(let MA=0;MA<vA.length;MA++)oA(vA[MA],bA);vA.length===2?$(k,x,b):k.projectionMatrix.copy(x.projectionMatrix),IA(pA,k,bA)};function IA(pA,bA,vA){vA===null?pA.matrix.copy(bA.matrixWorld):(pA.matrix.copy(vA.matrixWorld),pA.matrix.invert(),pA.matrix.multiply(bA.matrixWorld)),pA.matrix.decompose(pA.position,pA.quaternion,pA.scale),pA.updateMatrixWorld(!0),pA.projectionMatrix.copy(bA.projectionMatrix),pA.projectionMatrixInverse.copy(bA.projectionMatrixInverse),pA.isPerspectiveCamera&&(pA.fov=x_*2*Math.atan(1/pA.projectionMatrix.elements[5]),pA.zoom=1)}this.getCamera=function(){return k},this.getFoveation=function(){if(!(B===null&&C===null))return a},this.setFoveation=function(pA){a=pA,B!==null&&(B.fixedFoveation=pA),C!==null&&C.fixedFoveation!==void 0&&(C.fixedFoveation=pA)},this.hasDepthSensing=function(){return Q.texture!==null},this.getDepthSensingMesh=function(){return Q.getMesh(k)};let tA=null;function sA(pA,bA){if(I=bA.getViewerPose(g||s),l=bA,I!==null){const vA=I.views;C!==null&&(A.setRenderTargetFramebuffer(u,C.framebuffer),A.setRenderTarget(u));let MA=!1;vA.length!==k.cameras.length&&(k.cameras.length=0,MA=!0);for(let CA=0;CA<vA.length;CA++){const mA=vA[CA];let uA=null;if(C!==null)uA=C.getViewport(mA);else{const ee=c.getViewSubImage(B,mA);uA=ee.viewport,CA===0&&(A.setRenderTargetTextures(u,ee.colorTexture,B.ignoreDepthValues?void 0:ee.depthStencilTexture),A.setRenderTarget(u))}let PA=F[CA];PA===void 0&&(PA=new sE,PA.layers.enable(CA),PA.viewport=new ug,F[CA]=PA),PA.matrix.fromArray(mA.transform.matrix),PA.matrix.decompose(PA.position,PA.quaternion,PA.scale),PA.projectionMatrix.fromArray(mA.projectionMatrix),PA.projectionMatrixInverse.copy(PA.projectionMatrix).invert(),PA.viewport.set(uA.x,uA.y,uA.width,uA.height),CA===0&&(k.matrix.copy(PA.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale)),MA===!0&&k.cameras.push(PA)}const qA=o.enabledFeatures;if(qA&&qA.includes("depth-sensing")){const CA=c.getDepthInformation(vA[0]);CA&&CA.isValid&&CA.texture&&Q.init(A,CA,o.renderState)}}for(let vA=0;vA<d.length;vA++){const MA=f[vA],qA=d[vA];MA!==null&&qA!==void 0&&qA.update(MA,bA,g||s)}tA&&tA(pA,bA),bA.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:bA}),l=null}const gA=new LSA;gA.setAnimationLoop(sA),this.setAnimationLoop=function(pA){tA=pA},this.dispose=function(){}}}const qk=new Np,LDe=new os;function HDe(t,A){function e(E,h){E.matrixAutoUpdate===!0&&E.updateMatrix(),h.value.copy(E.matrix)}function i(E,h){h.color.getRGB(E.fogColor.value,_SA(t)),h.isFog?(E.fogNear.value=h.near,E.fogFar.value=h.far):h.isFogExp2&&(E.fogDensity.value=h.density)}function o(E,h,u,d,f){h.isMeshBasicMaterial||h.isMeshLambertMaterial?n(E,h):h.isMeshToonMaterial?(n(E,h),c(E,h)):h.isMeshPhongMaterial?(n(E,h),I(E,h)):h.isMeshStandardMaterial?(n(E,h),B(E,h),h.isMeshPhysicalMaterial&&C(E,h,f)):h.isMeshMatcapMaterial?(n(E,h),l(E,h)):h.isMeshDepthMaterial?n(E,h):h.isMeshDistanceMaterial?(n(E,h),Q(E,h)):h.isMeshNormalMaterial?n(E,h):h.isLineBasicMaterial?(s(E,h),h.isLineDashedMaterial&&r(E,h)):h.isPointsMaterial?a(E,h,u,d):h.isSpriteMaterial?g(E,h):h.isShadowMaterial?(E.color.value.copy(h.color),E.opacity.value=h.opacity):h.isShaderMaterial&&(h.uniformsNeedUpdate=!1)}function n(E,h){E.opacity.value=h.opacity,h.color&&E.diffuse.value.copy(h.color),h.emissive&&E.emissive.value.copy(h.emissive).multiplyScalar(h.emissiveIntensity),h.map&&(E.map.value=h.map,e(h.map,E.mapTransform)),h.alphaMap&&(E.alphaMap.value=h.alphaMap,e(h.alphaMap,E.alphaMapTransform)),h.bumpMap&&(E.bumpMap.value=h.bumpMap,e(h.bumpMap,E.bumpMapTransform),E.bumpScale.value=h.bumpScale,h.side===rh&&(E.bumpScale.value*=-1)),h.normalMap&&(E.normalMap.value=h.normalMap,e(h.normalMap,E.normalMapTransform),E.normalScale.value.copy(h.normalScale),h.side===rh&&E.normalScale.value.negate()),h.displacementMap&&(E.displacementMap.value=h.displacementMap,e(h.displacementMap,E.displacementMapTransform),E.displacementScale.value=h.displacementScale,E.displacementBias.value=h.displacementBias),h.emissiveMap&&(E.emissiveMap.value=h.emissiveMap,e(h.emissiveMap,E.emissiveMapTransform)),h.specularMap&&(E.specularMap.value=h.specularMap,e(h.specularMap,E.specularMapTransform)),h.alphaTest>0&&(E.alphaTest.value=h.alphaTest);const u=A.get(h),d=u.envMap,f=u.envMapRotation;d&&(E.envMap.value=d,qk.copy(f),qk.x*=-1,qk.y*=-1,qk.z*=-1,d.isCubeTexture&&d.isRenderTargetTexture===!1&&(qk.y*=-1,qk.z*=-1),E.envMapRotation.value.setFromMatrix4(LDe.makeRotationFromEuler(qk)),E.flipEnvMap.value=d.isCubeTexture&&d.isRenderTargetTexture===!1?-1:1,E.reflectivity.value=h.reflectivity,E.ior.value=h.ior,E.refractionRatio.value=h.refractionRatio),h.lightMap&&(E.lightMap.value=h.lightMap,E.lightMapIntensity.value=h.lightMapIntensity,e(h.lightMap,E.lightMapTransform)),h.aoMap&&(E.aoMap.value=h.aoMap,E.aoMapIntensity.value=h.aoMapIntensity,e(h.aoMap,E.aoMapTransform))}function s(E,h){E.diffuse.value.copy(h.color),E.opacity.value=h.opacity,h.map&&(E.map.value=h.map,e(h.map,E.mapTransform))}function r(E,h){E.dashSize.value=h.dashSize,E.totalSize.value=h.dashSize+h.gapSize,E.scale.value=h.scale}function a(E,h,u,d){E.diffuse.value.copy(h.color),E.opacity.value=h.opacity,E.size.value=h.size*u,E.scale.value=d*.5,h.map&&(E.map.value=h.map,e(h.map,E.uvTransform)),h.alphaMap&&(E.alphaMap.value=h.alphaMap,e(h.alphaMap,E.alphaMapTransform)),h.alphaTest>0&&(E.alphaTest.value=h.alphaTest)}function g(E,h){E.diffuse.value.copy(h.color),E.opacity.value=h.opacity,E.rotation.value=h.rotation,h.map&&(E.map.value=h.map,e(h.map,E.mapTransform)),h.alphaMap&&(E.alphaMap.value=h.alphaMap,e(h.alphaMap,E.alphaMapTransform)),h.alphaTest>0&&(E.alphaTest.value=h.alphaTest)}function I(E,h){E.specular.value.copy(h.specular),E.shininess.value=Math.max(h.shininess,1e-4)}function c(E,h){h.gradientMap&&(E.gradientMap.value=h.gradientMap)}function B(E,h){E.metalness.value=h.metalness,h.metalnessMap&&(E.metalnessMap.value=h.metalnessMap,e(h.metalnessMap,E.metalnessMapTransform)),E.roughness.value=h.roughness,h.roughnessMap&&(E.roughnessMap.value=h.roughnessMap,e(h.roughnessMap,E.roughnessMapTransform)),h.envMap&&(E.envMapIntensity.value=h.envMapIntensity)}function C(E,h,u){E.ior.value=h.ior,h.sheen>0&&(E.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),E.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(E.sheenColorMap.value=h.sheenColorMap,e(h.sheenColorMap,E.sheenColorMapTransform)),h.sheenRoughnessMap&&(E.sheenRoughnessMap.value=h.sheenRoughnessMap,e(h.sheenRoughnessMap,E.sheenRoughnessMapTransform))),h.clearcoat>0&&(E.clearcoat.value=h.clearcoat,E.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(E.clearcoatMap.value=h.clearcoatMap,e(h.clearcoatMap,E.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(E.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,e(h.clearcoatRoughnessMap,E.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(E.clearcoatNormalMap.value=h.clearcoatNormalMap,e(h.clearcoatNormalMap,E.clearcoatNormalMapTransform),E.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===rh&&E.clearcoatNormalScale.value.negate())),h.dispersion>0&&(E.dispersion.value=h.dispersion),h.iridescence>0&&(E.iridescence.value=h.iridescence,E.iridescenceIOR.value=h.iridescenceIOR,E.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],E.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(E.iridescenceMap.value=h.iridescenceMap,e(h.iridescenceMap,E.iridescenceMapTransform)),h.iridescenceThicknessMap&&(E.iridescenceThicknessMap.value=h.iridescenceThicknessMap,e(h.iridescenceThicknessMap,E.iridescenceThicknessMapTransform))),h.transmission>0&&(E.transmission.value=h.transmission,E.transmissionSamplerMap.value=u.texture,E.transmissionSamplerSize.value.set(u.width,u.height),h.transmissionMap&&(E.transmissionMap.value=h.transmissionMap,e(h.transmissionMap,E.transmissionMapTransform)),E.thickness.value=h.thickness,h.thicknessMap&&(E.thicknessMap.value=h.thicknessMap,e(h.thicknessMap,E.thicknessMapTransform)),E.attenuationDistance.value=h.attenuationDistance,E.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(E.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(E.anisotropyMap.value=h.anisotropyMap,e(h.anisotropyMap,E.anisotropyMapTransform))),E.specularIntensity.value=h.specularIntensity,E.specularColor.value.copy(h.specularColor),h.specularColorMap&&(E.specularColorMap.value=h.specularColorMap,e(h.specularColorMap,E.specularColorMapTransform)),h.specularIntensityMap&&(E.specularIntensityMap.value=h.specularIntensityMap,e(h.specularIntensityMap,E.specularIntensityMapTransform))}function l(E,h){h.matcap&&(E.matcap.value=h.matcap)}function Q(E,h){const u=A.get(h).light;E.referencePosition.value.setFromMatrixPosition(u.matrixWorld),E.nearDistance.value=u.shadow.camera.near,E.farDistance.value=u.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:o}}function YDe(t,A,e,i){let o={},n={},s=[];const r=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function a(u,d){const f=d.program;i.uniformBlockBinding(u,f)}function g(u,d){let f=o[u.id];f===void 0&&(l(u),f=I(u),o[u.id]=f,u.addEventListener("dispose",E));const D=d.program;i.updateUBOMapping(u,D);const w=A.render.frame;n[u.id]!==w&&(B(u),n[u.id]=w)}function I(u){const d=c();u.__bindingPointIndex=d;const f=t.createBuffer(),D=u.__size,w=u.usage;return t.bindBuffer(t.UNIFORM_BUFFER,f),t.bufferData(t.UNIFORM_BUFFER,D,w),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,d,f),f}function c(){for(let u=0;u<r;u++)if(s.indexOf(u)===-1)return s.push(u),u;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function B(u){const d=o[u.id],f=u.uniforms,D=u.__cache;t.bindBuffer(t.UNIFORM_BUFFER,d);for(let w=0,x=f.length;w<x;w++){const b=Array.isArray(f[w])?f[w]:[f[w]];for(let F=0,k=b.length;F<k;F++){const U=b[F];if(C(U,w,F,D)===!0){const N=U.__offset,J=Array.isArray(U.value)?U.value:[U.value];let P=0;for(let T=0;T<J.length;T++){const O=J[T],W=Q(O);typeof O=="number"||typeof O=="boolean"?(U.__data[0]=O,t.bufferSubData(t.UNIFORM_BUFFER,N+P,U.__data)):O.isMatrix3?(U.__data[0]=O.elements[0],U.__data[1]=O.elements[1],U.__data[2]=O.elements[2],U.__data[3]=0,U.__data[4]=O.elements[3],U.__data[5]=O.elements[4],U.__data[6]=O.elements[5],U.__data[7]=0,U.__data[8]=O.elements[6],U.__data[9]=O.elements[7],U.__data[10]=O.elements[8],U.__data[11]=0):(O.toArray(U.__data,P),P+=W.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,N,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function C(u,d,f,D){const w=u.value,x=d+"_"+f;if(D[x]===void 0)return typeof w=="number"||typeof w=="boolean"?D[x]=w:D[x]=w.clone(),!0;{const b=D[x];if(typeof w=="number"||typeof w=="boolean"){if(b!==w)return D[x]=w,!0}else if(b.equals(w)===!1)return b.copy(w),!0}return!1}function l(u){const d=u.uniforms;let f=0;const D=16;for(let x=0,b=d.length;x<b;x++){const F=Array.isArray(d[x])?d[x]:[d[x]];for(let k=0,U=F.length;k<U;k++){const N=F[k],J=Array.isArray(N.value)?N.value:[N.value];for(let P=0,T=J.length;P<T;P++){const O=J[P],W=Q(O),$=f%D;$!==0&&D-$<W.boundary&&(f+=D-$),N.__data=new Float32Array(W.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=f,f+=W.storage}}}const w=f%D;return w>0&&(f+=D-w),u.__size=f,u.__cache={},this}function Q(u){const d={boundary:0,storage:0};return typeof u=="number"||typeof u=="boolean"?(d.boundary=4,d.storage=4):u.isVector2?(d.boundary=8,d.storage=8):u.isVector3||u.isColor?(d.boundary=16,d.storage=12):u.isVector4?(d.boundary=16,d.storage=16):u.isMatrix3?(d.boundary=48,d.storage=48):u.isMatrix4?(d.boundary=64,d.storage=64):u.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",u),d}function E(u){const d=u.target;d.removeEventListener("dispose",E);const f=s.indexOf(d.__bindingPointIndex);s.splice(f,1),t.deleteBuffer(o[d.id]),delete o[d.id],delete n[d.id]}function h(){for(const u in o)t.deleteBuffer(o[u]);s=[],o={},n={}}return{bind:a,update:g,dispose:h}}class kK{constructor(A={}){const{canvas:e=E0e(),context:i=null,depth:o=!0,stencil:n=!1,alpha:s=!1,antialias:r=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:g=!1,powerPreference:I="default",failIfMajorPerformanceCaveat:c=!1}=A;this.isWebGLRenderer=!0;let B;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");B=i.getContextAttributes().alpha}else B=s;const C=new Uint32Array(4),l=new Int32Array(4);let Q=null,E=null;const h=[],u=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Wy,this.toneMapping=lb,this.toneMappingExposure=1;const d=this;let f=!1,D=0,w=0,x=null,b=-1,F=null;const k=new ug,U=new ug;let N=null;const J=new Li(0);let P=0,T=e.width,O=e.height,W=1,$=null,oA=null;const IA=new ug(0,0,T,O),tA=new ug(0,0,T,O);let sA=!1;const gA=new Oj;let pA=!1,bA=!1;const vA=new os,MA=new _e,qA={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let CA=!1;function mA(){return x===null?W:1}let uA=i;function PA(Qe,Le){return e.getContext(Qe,Le)}try{const Qe={alpha:!0,depth:o,stencil:n,antialias:r,premultipliedAlpha:a,preserveDrawingBuffer:g,powerPreference:I,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${VJ}`),e.addEventListener("webglcontextlost",ae,!1),e.addEventListener("webglcontextrestored",Ce,!1),e.addEventListener("webglcontextcreationerror",me,!1),uA===null){const Le="webgl2";if(uA=PA(Le,Qe),uA===null)throw PA(Le)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(Qe){throw console.error("THREE.WebGLRenderer: "+Qe.message),Qe}let ee,Be,yA,WA,KA,JA,jA,GA,SA,_A,FA,TA,OA,oe,DA,BA,QA,YA,se,he,De,Fe,Xe,Ve;function lt(){ee=new zme(uA),ee.init(),Fe=new FDe(uA,ee),Be=new Pme(uA,ee,A,Fe),yA=new kDe(uA),WA=new Awe(uA),KA=new hDe,JA=new GDe(uA,ee,yA,KA,Be,Fe,WA),jA=new Wme(d),GA=new jme(d),SA=new J0e(uA),Xe=new Tme(uA,SA),_A=new Xme(uA,SA,WA,Xe),FA=new twe(uA,_A,SA,WA),se=new ewe(uA,Be,JA),BA=new Ome(KA),TA=new EDe(d,jA,GA,ee,Be,Xe,BA),OA=new HDe(d,KA),oe=new dDe,DA=new DDe(ee),YA=new Kme(d,jA,GA,yA,FA,B,a),QA=new xDe(d,FA,Be),Ve=new YDe(uA,WA,Be,yA),he=new qme(uA,ee,WA),De=new $me(uA,ee,WA),WA.programs=TA.programs,d.capabilities=Be,d.extensions=ee,d.properties=KA,d.renderLists=oe,d.shadowMap=QA,d.state=yA,d.info=WA}lt();const EA=new UDe(d,uA);this.xr=EA,this.getContext=function(){return uA},this.getContextAttributes=function(){return uA.getContextAttributes()},this.forceContextLoss=function(){const Qe=ee.get("WEBGL_lose_context");Qe&&Qe.loseContext()},this.forceContextRestore=function(){const Qe=ee.get("WEBGL_lose_context");Qe&&Qe.restoreContext()},this.getPixelRatio=function(){return W},this.setPixelRatio=function(Qe){Qe!==void 0&&(W=Qe,this.setSize(T,O,!1))},this.getSize=function(Qe){return Qe.set(T,O)},this.setSize=function(Qe,Le,$e=!0){if(EA.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=Qe,O=Le,e.width=Math.floor(Qe*W),e.height=Math.floor(Le*W),$e===!0&&(e.style.width=Qe+"px",e.style.height=Le+"px"),this.setViewport(0,0,Qe,Le)},this.getDrawingBufferSize=function(Qe){return Qe.set(T*W,O*W).floor()},this.setDrawingBufferSize=function(Qe,Le,$e){T=Qe,O=Le,W=$e,e.width=Math.floor(Qe*$e),e.height=Math.floor(Le*$e),this.setViewport(0,0,Qe,Le)},this.getCurrentViewport=function(Qe){return Qe.copy(k)},this.getViewport=function(Qe){return Qe.copy(IA)},this.setViewport=function(Qe,Le,$e,ze){Qe.isVector4?IA.set(Qe.x,Qe.y,Qe.z,Qe.w):IA.set(Qe,Le,$e,ze),yA.viewport(k.copy(IA).multiplyScalar(W).round())},this.getScissor=function(Qe){return Qe.copy(tA)},this.setScissor=function(Qe,Le,$e,ze){Qe.isVector4?tA.set(Qe.x,Qe.y,Qe.z,Qe.w):tA.set(Qe,Le,$e,ze),yA.scissor(U.copy(tA).multiplyScalar(W).round())},this.getScissorTest=function(){return sA},this.setScissorTest=function(Qe){yA.setScissorTest(sA=Qe)},this.setOpaqueSort=function(Qe){$=Qe},this.setTransparentSort=function(Qe){oA=Qe},this.getClearColor=function(Qe){return Qe.copy(YA.getClearColor())},this.setClearColor=function(){YA.setClearColor.apply(YA,arguments)},this.getClearAlpha=function(){return YA.getClearAlpha()},this.setClearAlpha=function(){YA.setClearAlpha.apply(YA,arguments)},this.clear=function(Qe=!0,Le=!0,$e=!0){let ze=0;if(Qe){let Je=!1;if(x!==null){const qt=x.texture.format;Je=qt===xDA||qt===bDA||qt===SDA}if(Je){const qt=x.texture.type,Ut=qt===Qb||qt===p_||qt===$J||qt===f_||qt===mDA||qt===wDA,ti=YA.getClearColor(),ri=YA.getClearAlpha(),Ht=ti.r,so=ti.g,Yi=ti.b;Ut?(C[0]=Ht,C[1]=so,C[2]=Yi,C[3]=ri,uA.clearBufferuiv(uA.COLOR,0,C)):(l[0]=Ht,l[1]=so,l[2]=Yi,l[3]=ri,uA.clearBufferiv(uA.COLOR,0,l))}else ze|=uA.COLOR_BUFFER_BIT}Le&&(ze|=uA.DEPTH_BUFFER_BIT),$e&&(ze|=uA.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),uA.clear(ze)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",ae,!1),e.removeEventListener("webglcontextrestored",Ce,!1),e.removeEventListener("webglcontextcreationerror",me,!1),oe.dispose(),DA.dispose(),KA.dispose(),jA.dispose(),GA.dispose(),FA.dispose(),Xe.dispose(),Ve.dispose(),TA.dispose(),EA.dispose(),EA.removeEventListener("sessionstart",Ft),EA.removeEventListener("sessionend",Mt),Tt.stop()};function ae(Qe){Qe.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),f=!0}function Ce(){console.log("THREE.WebGLRenderer: Context Restored."),f=!1;const Qe=WA.autoReset,Le=QA.enabled,$e=QA.autoUpdate,ze=QA.needsUpdate,Je=QA.type;lt(),WA.autoReset=Qe,QA.enabled=Le,QA.autoUpdate=$e,QA.needsUpdate=ze,QA.type=Je}function me(Qe){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Qe.statusMessage)}function Ue(Qe){const Le=Qe.target;Le.removeEventListener("dispose",Ue),Ye(Le)}function Ye(Qe){gt(Qe),KA.remove(Qe)}function gt(Qe){const Le=KA.get(Qe).programs;Le!==void 0&&(Le.forEach(function($e){TA.releaseProgram($e)}),Qe.isShaderMaterial&&TA.releaseShaderCache(Qe))}this.renderBufferDirect=function(Qe,Le,$e,ze,Je,qt){Le===null&&(Le=qA);const Ut=Je.isMesh&&Je.matrixWorld.determinant()<0,ti=At(Qe,Le,$e,ze,Je);yA.setMaterial(ze,Ut);let ri=$e.index,Ht=1;if(ze.wireframe===!0){if(ri=_A.getWireframeAttribute($e),ri===void 0)return;Ht=2}const so=$e.drawRange,Yi=$e.attributes.position;let ao=so.start*Ht,an=(so.start+so.count)*Ht;qt!==null&&(ao=Math.max(ao,qt.start*Ht),an=Math.min(an,(qt.start+qt.count)*Ht)),ri!==null?(ao=Math.max(ao,0),an=Math.min(an,ri.count)):Yi!=null&&(ao=Math.max(ao,0),an=Math.min(an,Yi.count));const pn=an-ao;if(pn<0||pn===1/0)return;Xe.setup(Je,ze,ti,$e,ri);let jn,qi=he;if(ri!==null&&(jn=SA.get(ri),qi=De,qi.setIndex(jn)),Je.isMesh)ze.wireframe===!0?(yA.setLineWidth(ze.wireframeLinewidth*mA()),qi.setMode(uA.LINES)):qi.setMode(uA.TRIANGLES);else if(Je.isLine){let fi=ze.linewidth;fi===void 0&&(fi=1),yA.setLineWidth(fi*mA()),Je.isLineSegments?qi.setMode(uA.LINES):Je.isLineLoop?qi.setMode(uA.LINE_LOOP):qi.setMode(uA.LINE_STRIP)}else Je.isPoints?qi.setMode(uA.POINTS):Je.isSprite&&qi.setMode(uA.TRIANGLES);if(Je.isBatchedMesh)Je._multiDrawInstances!==null?qi.renderMultiDrawInstances(Je._multiDrawStarts,Je._multiDrawCounts,Je._multiDrawCount,Je._multiDrawInstances):qi.renderMultiDraw(Je._multiDrawStarts,Je._multiDrawCounts,Je._multiDrawCount);else if(Je.isInstancedMesh)qi.renderInstances(ao,pn,Je.count);else if($e.isInstancedBufferGeometry){const fi=$e._maxInstanceCount!==void 0?$e._maxInstanceCount:1/0,zo=Math.min($e.instanceCount,fi);qi.renderInstances(ao,pn,zo)}else qi.render(ao,pn)};function Jt(Qe,Le,$e){Qe.transparent===!0&&Qe.side===JC&&Qe.forceSinglePass===!1?(Qe.side=rh,Qe.needsUpdate=!0,Lt(Qe,Le,$e),Qe.side=Oy,Qe.needsUpdate=!0,Lt(Qe,Le,$e),Qe.side=JC):Lt(Qe,Le,$e)}this.compile=function(Qe,Le,$e=null){$e===null&&($e=Qe),E=DA.get($e),E.init(Le),u.push(E),$e.traverseVisible(function(Je){Je.isLight&&Je.layers.test(Le.layers)&&(E.pushLight(Je),Je.castShadow&&E.pushShadow(Je))}),Qe!==$e&&Qe.traverseVisible(function(Je){Je.isLight&&Je.layers.test(Le.layers)&&(E.pushLight(Je),Je.castShadow&&E.pushShadow(Je))}),E.setupLights();const ze=new Set;return Qe.traverse(function(Je){const qt=Je.material;if(qt)if(Array.isArray(qt))for(let Ut=0;Ut<qt.length;Ut++){const ti=qt[Ut];Jt(ti,$e,Je),ze.add(ti)}else Jt(qt,$e,Je),ze.add(qt)}),u.pop(),E=null,ze},this.compileAsync=function(Qe,Le,$e=null){const ze=this.compile(Qe,Le,$e);return new Promise(Je=>{function qt(){if(ze.forEach(function(Ut){KA.get(Ut).currentProgram.isReady()&&ze.delete(Ut)}),ze.size===0){Je(Qe);return}setTimeout(qt,10)}ee.get("KHR_parallel_shader_compile")!==null?qt():setTimeout(qt,10)})};let St=null;function ot(Qe){St&&St(Qe)}function Ft(){Tt.stop()}function Mt(){Tt.start()}const Tt=new LSA;Tt.setAnimationLoop(ot),typeof self<"u"&&Tt.setContext(self),this.setAnimationLoop=function(Qe){St=Qe,EA.setAnimationLoop(Qe),Qe===null?Tt.stop():Tt.start()},EA.addEventListener("sessionstart",Ft),EA.addEventListener("sessionend",Mt),this.render=function(Qe,Le){if(Le!==void 0&&Le.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(f===!0)return;if(Qe.matrixWorldAutoUpdate===!0&&Qe.updateMatrixWorld(),Le.parent===null&&Le.matrixWorldAutoUpdate===!0&&Le.updateMatrixWorld(),EA.enabled===!0&&EA.isPresenting===!0&&(EA.cameraAutoUpdate===!0&&EA.updateCamera(Le),Le=EA.getCamera()),Qe.isScene===!0&&Qe.onBeforeRender(d,Qe,Le,x),E=DA.get(Qe,u.length),E.init(Le),u.push(E),vA.multiplyMatrices(Le.projectionMatrix,Le.matrixWorldInverse),gA.setFromProjectionMatrix(vA),bA=this.localClippingEnabled,pA=BA.init(this.clippingPlanes,bA),Q=oe.get(Qe,h.length),Q.init(),h.push(Q),EA.enabled===!0&&EA.isPresenting===!0){const qt=d.xr.getDepthSensingMesh();qt!==null&&vt(qt,Le,-1/0,d.sortObjects)}vt(Qe,Le,0,d.sortObjects),Q.finish(),d.sortObjects===!0&&Q.sort($,oA),CA=EA.enabled===!1||EA.isPresenting===!1||EA.hasDepthSensing()===!1,CA&&YA.addToRenderList(Q,Qe),this.info.render.frame++,pA===!0&&BA.beginShadows();const $e=E.state.shadowsArray;QA.render($e,Qe,Le),pA===!0&&BA.endShadows(),this.info.autoReset===!0&&this.info.reset();const ze=Q.opaque,Je=Q.transmissive;if(E.setupLights(),Le.isArrayCamera){const qt=Le.cameras;if(Je.length>0)for(let Ut=0,ti=qt.length;Ut<ti;Ut++){const ri=qt[Ut];ue(ze,Je,Qe,ri)}CA&&YA.render(Qe);for(let Ut=0,ti=qt.length;Ut<ti;Ut++){const ri=qt[Ut];Nt(Q,Qe,ri,ri.viewport)}}else Je.length>0&&ue(ze,Je,Qe,Le),CA&&YA.render(Qe),Nt(Q,Qe,Le);x!==null&&(JA.updateMultisampleRenderTarget(x),JA.updateRenderTargetMipmap(x)),Qe.isScene===!0&&Qe.onAfterRender(d,Qe,Le),Xe.resetDefaultState(),b=-1,F=null,u.pop(),u.length>0?(E=u[u.length-1],pA===!0&&BA.setGlobalState(d.clippingPlanes,E.state.camera)):E=null,h.pop(),h.length>0?Q=h[h.length-1]:Q=null};function vt(Qe,Le,$e,ze){if(Qe.visible===!1)return;if(Qe.layers.test(Le.layers)){if(Qe.isGroup)$e=Qe.renderOrder;else if(Qe.isLOD)Qe.autoUpdate===!0&&Qe.update(Le);else if(Qe.isLight)E.pushLight(Qe),Qe.castShadow&&E.pushShadow(Qe);else if(Qe.isSprite){if(!Qe.frustumCulled||gA.intersectsSprite(Qe)){ze&&MA.setFromMatrixPosition(Qe.matrixWorld).applyMatrix4(vA);const Ut=FA.update(Qe),ti=Qe.material;ti.visible&&Q.push(Qe,Ut,ti,$e,MA.z,null)}}else if((Qe.isMesh||Qe.isLine||Qe.isPoints)&&(!Qe.frustumCulled||gA.intersectsObject(Qe))){const Ut=FA.update(Qe),ti=Qe.material;if(ze&&(Qe.boundingSphere!==void 0?(Qe.boundingSphere===null&&Qe.computeBoundingSphere(),MA.copy(Qe.boundingSphere.center)):(Ut.boundingSphere===null&&Ut.computeBoundingSphere(),MA.copy(Ut.boundingSphere.center)),MA.applyMatrix4(Qe.matrixWorld).applyMatrix4(vA)),Array.isArray(ti)){const ri=Ut.groups;for(let Ht=0,so=ri.length;Ht<so;Ht++){const Yi=ri[Ht],ao=ti[Yi.materialIndex];ao&&ao.visible&&Q.push(Qe,Ut,ao,$e,MA.z,Yi)}}else ti.visible&&Q.push(Qe,Ut,ti,$e,MA.z,null)}}const qt=Qe.children;for(let Ut=0,ti=qt.length;Ut<ti;Ut++)vt(qt[Ut],Le,$e,ze)}function Nt(Qe,Le,$e,ze){const Je=Qe.opaque,qt=Qe.transmissive,Ut=Qe.transparent;E.setupLightsView($e),pA===!0&&BA.setGlobalState(d.clippingPlanes,$e),ze&&yA.viewport(k.copy(ze)),Je.length>0&&Te(Je,Le,$e),qt.length>0&&Te(qt,Le,$e),Ut.length>0&&Te(Ut,Le,$e),yA.buffers.depth.setTest(!0),yA.buffers.depth.setMask(!0),yA.buffers.color.setMask(!0),yA.setPolygonOffset(!1)}function ue(Qe,Le,$e,ze){if(($e.isScene===!0?$e.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[ze.id]===void 0&&(E.state.transmissionRenderTarget[ze.id]=new vk(1,1,{generateMipmaps:!0,type:ee.has("EXT_color_buffer_half_float")||ee.has("EXT_color_buffer_float")?AK:Qb,minFilter:Ed,samples:4,stencilBuffer:n,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:hg.workingColorSpace}));const qt=E.state.transmissionRenderTarget[ze.id],Ut=ze.viewport||k;qt.setSize(Ut.z,Ut.w);const ti=d.getRenderTarget();d.setRenderTarget(qt),d.getClearColor(J),P=d.getClearAlpha(),P<1&&d.setClearColor(16777215,.5),CA?YA.render($e):d.clear();const ri=d.toneMapping;d.toneMapping=lb;const Ht=ze.viewport;if(ze.viewport!==void 0&&(ze.viewport=void 0),E.setupLightsView(ze),pA===!0&&BA.setGlobalState(d.clippingPlanes,ze),Te(Qe,$e,ze),JA.updateMultisampleRenderTarget(qt),JA.updateRenderTargetMipmap(qt),ee.has("WEBGL_multisampled_render_to_texture")===!1){let so=!1;for(let Yi=0,ao=Le.length;Yi<ao;Yi++){const an=Le[Yi],pn=an.object,jn=an.geometry,qi=an.material,fi=an.group;if(qi.side===JC&&pn.layers.test(ze.layers)){const zo=qi.side;qi.side=rh,qi.needsUpdate=!0,dt(pn,$e,ze,jn,qi,fi),qi.side=zo,qi.needsUpdate=!0,so=!0}}so===!0&&(JA.updateMultisampleRenderTarget(qt),JA.updateRenderTargetMipmap(qt))}d.setRenderTarget(ti),d.setClearColor(J,P),Ht!==void 0&&(ze.viewport=Ht),d.toneMapping=ri}function Te(Qe,Le,$e){const ze=Le.isScene===!0?Le.overrideMaterial:null;for(let Je=0,qt=Qe.length;Je<qt;Je++){const Ut=Qe[Je],ti=Ut.object,ri=Ut.geometry,Ht=ze===null?Ut.material:ze,so=Ut.group;ti.layers.test($e.layers)&&dt(ti,Le,$e,ri,Ht,so)}}function dt(Qe,Le,$e,ze,Je,qt){Qe.onBeforeRender(d,Le,$e,ze,Je,qt),Qe.modelViewMatrix.multiplyMatrices($e.matrixWorldInverse,Qe.matrixWorld),Qe.normalMatrix.getNormalMatrix(Qe.modelViewMatrix),Je.onBeforeRender(d,Le,$e,ze,Qe,qt),Je.transparent===!0&&Je.side===JC&&Je.forceSinglePass===!1?(Je.side=rh,Je.needsUpdate=!0,d.renderBufferDirect($e,Le,ze,Je,Qe,qt),Je.side=Oy,Je.needsUpdate=!0,d.renderBufferDirect($e,Le,ze,Je,Qe,qt),Je.side=JC):d.renderBufferDirect($e,Le,ze,Je,Qe,qt),Qe.onAfterRender(d,Le,$e,ze,Je,qt)}function Lt(Qe,Le,$e){Le.isScene!==!0&&(Le=qA);const ze=KA.get(Qe),Je=E.state.lights,qt=E.state.shadowsArray,Ut=Je.state.version,ti=TA.getParameters(Qe,Je.state,qt,Le,$e),ri=TA.getProgramCacheKey(ti);let Ht=ze.programs;ze.environment=Qe.isMeshStandardMaterial?Le.environment:null,ze.fog=Le.fog,ze.envMap=(Qe.isMeshStandardMaterial?GA:jA).get(Qe.envMap||ze.environment),ze.envMapRotation=ze.environment!==null&&Qe.envMap===null?Le.environmentRotation:Qe.envMapRotation,Ht===void 0&&(Qe.addEventListener("dispose",Ue),Ht=new Map,ze.programs=Ht);let so=Ht.get(ri);if(so!==void 0){if(ze.currentProgram===so&&ze.lightsStateVersion===Ut)return si(Qe,ti),so}else ti.uniforms=TA.getUniforms(Qe),Qe.onBuild($e,ti,d),Qe.onBeforeCompile(ti,d),so=TA.acquireProgram(ti,ri),Ht.set(ri,so),ze.uniforms=ti.uniforms;const Yi=ze.uniforms;return(!Qe.isShaderMaterial&&!Qe.isRawShaderMaterial||Qe.clipping===!0)&&(Yi.clippingPlanes=BA.uniform),si(Qe,ti),ze.needsLights=ji(Qe),ze.lightsStateVersion=Ut,ze.needsLights&&(Yi.ambientLightColor.value=Je.state.ambient,Yi.lightProbe.value=Je.state.probe,Yi.directionalLights.value=Je.state.directional,Yi.directionalLightShadows.value=Je.state.directionalShadow,Yi.spotLights.value=Je.state.spot,Yi.spotLightShadows.value=Je.state.spotShadow,Yi.rectAreaLights.value=Je.state.rectArea,Yi.ltc_1.value=Je.state.rectAreaLTC1,Yi.ltc_2.value=Je.state.rectAreaLTC2,Yi.pointLights.value=Je.state.point,Yi.pointLightShadows.value=Je.state.pointShadow,Yi.hemisphereLights.value=Je.state.hemi,Yi.directionalShadowMap.value=Je.state.directionalShadowMap,Yi.directionalShadowMatrix.value=Je.state.directionalShadowMatrix,Yi.spotShadowMap.value=Je.state.spotShadowMap,Yi.spotLightMatrix.value=Je.state.spotLightMatrix,Yi.spotLightMap.value=Je.state.spotLightMap,Yi.pointShadowMap.value=Je.state.pointShadowMap,Yi.pointShadowMatrix.value=Je.state.pointShadowMatrix),ze.currentProgram=so,ze.uniformsList=null,so}function Ni(Qe){if(Qe.uniformsList===null){const Le=Qe.currentProgram.getUniforms();Qe.uniformsList=xK.seqWithValue(Le.seq,Qe.uniforms)}return Qe.uniformsList}function si(Qe,Le){const $e=KA.get(Qe);$e.outputColorSpace=Le.outputColorSpace,$e.batching=Le.batching,$e.batchingColor=Le.batchingColor,$e.instancing=Le.instancing,$e.instancingColor=Le.instancingColor,$e.instancingMorph=Le.instancingMorph,$e.skinning=Le.skinning,$e.morphTargets=Le.morphTargets,$e.morphNormals=Le.morphNormals,$e.morphColors=Le.morphColors,$e.morphTargetsCount=Le.morphTargetsCount,$e.numClippingPlanes=Le.numClippingPlanes,$e.numIntersection=Le.numClipIntersection,$e.vertexAlphas=Le.vertexAlphas,$e.vertexTangents=Le.vertexTangents,$e.toneMapping=Le.toneMapping}function At(Qe,Le,$e,ze,Je){Le.isScene!==!0&&(Le=qA),JA.resetTextureUnits();const qt=Le.fog,Ut=ze.isMeshStandardMaterial?Le.environment:null,ti=x===null?d.outputColorSpace:x.isXRRenderTarget===!0?x.texture.colorSpace:hb,ri=(ze.isMeshStandardMaterial?GA:jA).get(ze.envMap||Ut),Ht=ze.vertexColors===!0&&!!$e.attributes.color&&$e.attributes.color.itemSize===4,so=!!$e.attributes.tangent&&(!!ze.normalMap||ze.anisotropy>0),Yi=!!$e.morphAttributes.position,ao=!!$e.morphAttributes.normal,an=!!$e.morphAttributes.color;let pn=lb;ze.toneMapped&&(x===null||x.isXRRenderTarget===!0)&&(pn=d.toneMapping);const jn=$e.morphAttributes.position||$e.morphAttributes.normal||$e.morphAttributes.color,qi=jn!==void 0?jn.length:0,fi=KA.get(ze),zo=E.state.lights;if(pA===!0&&(bA===!0||Qe!==F)){const qs=Qe===F&&ze.id===b;BA.setState(ze,Qe,qs)}let yi=!1;ze.version===fi.__version?(fi.needsLights&&fi.lightsStateVersion!==zo.state.version||fi.outputColorSpace!==ti||Je.isBatchedMesh&&fi.batching===!1||!Je.isBatchedMesh&&fi.batching===!0||Je.isBatchedMesh&&fi.batchingColor===!0&&Je.colorTexture===null||Je.isBatchedMesh&&fi.batchingColor===!1&&Je.colorTexture!==null||Je.isInstancedMesh&&fi.instancing===!1||!Je.isInstancedMesh&&fi.instancing===!0||Je.isSkinnedMesh&&fi.skinning===!1||!Je.isSkinnedMesh&&fi.skinning===!0||Je.isInstancedMesh&&fi.instancingColor===!0&&Je.instanceColor===null||Je.isInstancedMesh&&fi.instancingColor===!1&&Je.instanceColor!==null||Je.isInstancedMesh&&fi.instancingMorph===!0&&Je.morphTexture===null||Je.isInstancedMesh&&fi.instancingMorph===!1&&Je.morphTexture!==null||fi.envMap!==ri||ze.fog===!0&&fi.fog!==qt||fi.numClippingPlanes!==void 0&&(fi.numClippingPlanes!==BA.numPlanes||fi.numIntersection!==BA.numIntersection)||fi.vertexAlphas!==Ht||fi.vertexTangents!==so||fi.morphTargets!==Yi||fi.morphNormals!==ao||fi.morphColors!==an||fi.toneMapping!==pn||fi.morphTargetsCount!==qi)&&(yi=!0):(yi=!0,fi.__version=ze.version);let Qa=fi.currentProgram;yi===!0&&(Qa=Lt(ze,Le,Je));let ig=!1,Ms=!1,Ka=!1;const vs=Qa.getUniforms(),Us=fi.uniforms;if(yA.useProgram(Qa.program)&&(ig=!0,Ms=!0,Ka=!0),ze.id!==b&&(b=ze.id,Ms=!0),ig||F!==Qe){vs.setValue(uA,"projectionMatrix",Qe.projectionMatrix),vs.setValue(uA,"viewMatrix",Qe.matrixWorldInverse);const qs=vs.map.cameraPosition;qs!==void 0&&qs.setValue(uA,MA.setFromMatrixPosition(Qe.matrixWorld)),Be.logarithmicDepthBuffer&&vs.setValue(uA,"logDepthBufFC",2/(Math.log(Qe.far+1)/Math.LN2)),(ze.isMeshPhongMaterial||ze.isMeshToonMaterial||ze.isMeshLambertMaterial||ze.isMeshBasicMaterial||ze.isMeshStandardMaterial||ze.isShaderMaterial)&&vs.setValue(uA,"isOrthographic",Qe.isOrthographicCamera===!0),F!==Qe&&(F=Qe,Ms=!0,Ka=!0)}if(Je.isSkinnedMesh){vs.setOptional(uA,Je,"bindMatrix"),vs.setOptional(uA,Je,"bindMatrixInverse");const qs=Je.skeleton;qs&&(qs.boneTexture===null&&qs.computeBoneTexture(),vs.setValue(uA,"boneTexture",qs.boneTexture,JA))}Je.isBatchedMesh&&(vs.setOptional(uA,Je,"batchingTexture"),vs.setValue(uA,"batchingTexture",Je._matricesTexture,JA),vs.setOptional(uA,Je,"batchingColorTexture"),Je._colorsTexture!==null&&vs.setValue(uA,"batchingColorTexture",Je._colorsTexture,JA));const hI=$e.morphAttributes;if((hI.position!==void 0||hI.normal!==void 0||hI.color!==void 0)&&se.update(Je,$e,Qa),(Ms||fi.receiveShadow!==Je.receiveShadow)&&(fi.receiveShadow=Je.receiveShadow,vs.setValue(uA,"receiveShadow",Je.receiveShadow)),ze.isMeshGouraudMaterial&&ze.envMap!==null&&(Us.envMap.value=ri,Us.flipEnvMap.value=ri.isCubeTexture&&ri.isRenderTargetTexture===!1?-1:1),ze.isMeshStandardMaterial&&ze.envMap===null&&Le.environment!==null&&(Us.envMapIntensity.value=Le.environmentIntensity),Ms&&(vs.setValue(uA,"toneMappingExposure",d.toneMappingExposure),fi.needsLights&&rn(Us,Ka),qt&&ze.fog===!0&&OA.refreshFogUniforms(Us,qt),OA.refreshMaterialUniforms(Us,ze,W,O,E.state.transmissionRenderTarget[Qe.id]),xK.upload(uA,Ni(fi),Us,JA)),ze.isShaderMaterial&&ze.uniformsNeedUpdate===!0&&(xK.upload(uA,Ni(fi),Us,JA),ze.uniformsNeedUpdate=!1),ze.isSpriteMaterial&&vs.setValue(uA,"center",Je.center),vs.setValue(uA,"modelViewMatrix",Je.modelViewMatrix),vs.setValue(uA,"normalMatrix",Je.normalMatrix),vs.setValue(uA,"modelMatrix",Je.matrixWorld),ze.isShaderMaterial||ze.isRawShaderMaterial){const qs=ze.uniformsGroups;for(let Fl=0,kr=qs.length;Fl<kr;Fl++){const DQ=qs[Fl];Ve.update(DQ,Qa),Ve.bind(DQ,Qa)}}return Qa}function rn(Qe,Le){Qe.ambientLightColor.needsUpdate=Le,Qe.lightProbe.needsUpdate=Le,Qe.directionalLights.needsUpdate=Le,Qe.directionalLightShadows.needsUpdate=Le,Qe.pointLights.needsUpdate=Le,Qe.pointLightShadows.needsUpdate=Le,Qe.spotLights.needsUpdate=Le,Qe.spotLightShadows.needsUpdate=Le,Qe.rectAreaLights.needsUpdate=Le,Qe.hemisphereLights.needsUpdate=Le}function ji(Qe){return Qe.isMeshLambertMaterial||Qe.isMeshToonMaterial||Qe.isMeshPhongMaterial||Qe.isMeshStandardMaterial||Qe.isShadowMaterial||Qe.isShaderMaterial&&Qe.lights===!0}this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(Qe,Le,$e){KA.get(Qe.texture).__webglTexture=Le,KA.get(Qe.depthTexture).__webglTexture=$e;const ze=KA.get(Qe);ze.__hasExternalTextures=!0,ze.__autoAllocateDepthBuffer=$e===void 0,ze.__autoAllocateDepthBuffer||ee.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ze.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(Qe,Le){const $e=KA.get(Qe);$e.__webglFramebuffer=Le,$e.__useDefaultFramebuffer=Le===void 0},this.setRenderTarget=function(Qe,Le=0,$e=0){x=Qe,D=Le,w=$e;let ze=!0,Je=null,qt=!1,Ut=!1;if(Qe){const ri=KA.get(Qe);ri.__useDefaultFramebuffer!==void 0?(yA.bindFramebuffer(uA.FRAMEBUFFER,null),ze=!1):ri.__webglFramebuffer===void 0?JA.setupRenderTarget(Qe):ri.__hasExternalTextures&&JA.rebindTextures(Qe,KA.get(Qe.texture).__webglTexture,KA.get(Qe.depthTexture).__webglTexture);const Ht=Qe.texture;(Ht.isData3DTexture||Ht.isDataArrayTexture||Ht.isCompressedArrayTexture)&&(Ut=!0);const so=KA.get(Qe).__webglFramebuffer;Qe.isWebGLCubeRenderTarget?(Array.isArray(so[Le])?Je=so[Le][$e]:Je=so[Le],qt=!0):Qe.samples>0&&JA.useMultisampledRTT(Qe)===!1?Je=KA.get(Qe).__webglMultisampledFramebuffer:Array.isArray(so)?Je=so[$e]:Je=so,k.copy(Qe.viewport),U.copy(Qe.scissor),N=Qe.scissorTest}else k.copy(IA).multiplyScalar(W).floor(),U.copy(tA).multiplyScalar(W).floor(),N=sA;if(yA.bindFramebuffer(uA.FRAMEBUFFER,Je)&&ze&&yA.drawBuffers(Qe,Je),yA.viewport(k),yA.scissor(U),yA.setScissorTest(N),qt){const ri=KA.get(Qe.texture);uA.framebufferTexture2D(uA.FRAMEBUFFER,uA.COLOR_ATTACHMENT0,uA.TEXTURE_CUBE_MAP_POSITIVE_X+Le,ri.__webglTexture,$e)}else if(Ut){const ri=KA.get(Qe.texture),Ht=Le||0;uA.framebufferTextureLayer(uA.FRAMEBUFFER,uA.COLOR_ATTACHMENT0,ri.__webglTexture,$e||0,Ht)}b=-1},this.readRenderTargetPixels=function(Qe,Le,$e,ze,Je,qt,Ut){if(!(Qe&&Qe.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ti=KA.get(Qe).__webglFramebuffer;if(Qe.isWebGLCubeRenderTarget&&Ut!==void 0&&(ti=ti[Ut]),ti){yA.bindFramebuffer(uA.FRAMEBUFFER,ti);try{const ri=Qe.texture,Ht=ri.format,so=ri.type;if(!Be.textureFormatReadable(Ht)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Be.textureTypeReadable(so)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Le>=0&&Le<=Qe.width-ze&&$e>=0&&$e<=Qe.height-Je&&uA.readPixels(Le,$e,ze,Je,Fe.convert(Ht),Fe.convert(so),qt)}finally{const ri=x!==null?KA.get(x).__webglFramebuffer:null;yA.bindFramebuffer(uA.FRAMEBUFFER,ri)}}},this.readRenderTargetPixelsAsync=async function(Qe,Le,$e,ze,Je,qt,Ut){if(!(Qe&&Qe.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ti=KA.get(Qe).__webglFramebuffer;if(Qe.isWebGLCubeRenderTarget&&Ut!==void 0&&(ti=ti[Ut]),ti){yA.bindFramebuffer(uA.FRAMEBUFFER,ti);try{const ri=Qe.texture,Ht=ri.format,so=ri.type;if(!Be.textureFormatReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Be.textureTypeReadable(so))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(Le>=0&&Le<=Qe.width-ze&&$e>=0&&$e<=Qe.height-Je){const Yi=uA.createBuffer();uA.bindBuffer(uA.PIXEL_PACK_BUFFER,Yi),uA.bufferData(uA.PIXEL_PACK_BUFFER,qt.byteLength,uA.STREAM_READ),uA.readPixels(Le,$e,ze,Je,Fe.convert(Ht),Fe.convert(so),0),uA.flush();const ao=uA.fenceSync(uA.SYNC_GPU_COMMANDS_COMPLETE,0);await h0e(uA,ao,4);try{uA.bindBuffer(uA.PIXEL_PACK_BUFFER,Yi),uA.getBufferSubData(uA.PIXEL_PACK_BUFFER,0,qt)}finally{uA.deleteBuffer(Yi),uA.deleteSync(ao)}return qt}}finally{const ri=x!==null?KA.get(x).__webglFramebuffer:null;yA.bindFramebuffer(uA.FRAMEBUFFER,ri)}}},this.copyFramebufferToTexture=function(Qe,Le=null,$e=0){Qe.isTexture!==!0&&(console.warn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),Le=arguments[0]||null,Qe=arguments[1]);const ze=Math.pow(2,-$e),Je=Math.floor(Qe.image.width*ze),qt=Math.floor(Qe.image.height*ze),Ut=Le!==null?Le.x:0,ti=Le!==null?Le.y:0;JA.setTexture2D(Qe,0),uA.copyTexSubImage2D(uA.TEXTURE_2D,$e,0,0,Ut,ti,Je,qt),yA.unbindTexture()},this.copyTextureToTexture=function(Qe,Le,$e=null,ze=null,Je=0){Qe.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture function signature has changed."),ze=arguments[0]||null,Qe=arguments[1],Le=arguments[2],Je=arguments[3]||0,$e=null);let qt,Ut,ti,ri,Ht,so;$e!==null?(qt=$e.max.x-$e.min.x,Ut=$e.max.y-$e.min.y,ti=$e.min.x,ri=$e.min.y):(qt=Qe.image.width,Ut=Qe.image.height,ti=0,ri=0),ze!==null?(Ht=ze.x,so=ze.y):(Ht=0,so=0);const Yi=Fe.convert(Le.format),ao=Fe.convert(Le.type);JA.setTexture2D(Le,0),uA.pixelStorei(uA.UNPACK_FLIP_Y_WEBGL,Le.flipY),uA.pixelStorei(uA.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Le.premultiplyAlpha),uA.pixelStorei(uA.UNPACK_ALIGNMENT,Le.unpackAlignment);const an=uA.getParameter(uA.UNPACK_ROW_LENGTH),pn=uA.getParameter(uA.UNPACK_IMAGE_HEIGHT),jn=uA.getParameter(uA.UNPACK_SKIP_PIXELS),qi=uA.getParameter(uA.UNPACK_SKIP_ROWS),fi=uA.getParameter(uA.UNPACK_SKIP_IMAGES),zo=Qe.isCompressedTexture?Qe.mipmaps[Je]:Qe.image;uA.pixelStorei(uA.UNPACK_ROW_LENGTH,zo.width),uA.pixelStorei(uA.UNPACK_IMAGE_HEIGHT,zo.height),uA.pixelStorei(uA.UNPACK_SKIP_PIXELS,ti),uA.pixelStorei(uA.UNPACK_SKIP_ROWS,ri),Qe.isDataTexture?uA.texSubImage2D(uA.TEXTURE_2D,Je,Ht,so,qt,Ut,Yi,ao,zo.data):Qe.isCompressedTexture?uA.compressedTexSubImage2D(uA.TEXTURE_2D,Je,Ht,so,zo.width,zo.height,Yi,zo.data):uA.texSubImage2D(uA.TEXTURE_2D,Je,Ht,so,Yi,ao,zo),uA.pixelStorei(uA.UNPACK_ROW_LENGTH,an),uA.pixelStorei(uA.UNPACK_IMAGE_HEIGHT,pn),uA.pixelStorei(uA.UNPACK_SKIP_PIXELS,jn),uA.pixelStorei(uA.UNPACK_SKIP_ROWS,qi),uA.pixelStorei(uA.UNPACK_SKIP_IMAGES,fi),Je===0&&Le.generateMipmaps&&uA.generateMipmap(uA.TEXTURE_2D),yA.unbindTexture()},this.copyTextureToTexture3D=function(Qe,Le,$e=null,ze=null,Je=0){Qe.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),$e=arguments[0]||null,ze=arguments[1]||null,Qe=arguments[2],Le=arguments[3],Je=arguments[4]||0);let qt,Ut,ti,ri,Ht,so,Yi,ao,an;const pn=Qe.isCompressedTexture?Qe.mipmaps[Je]:Qe.image;$e!==null?(qt=$e.max.x-$e.min.x,Ut=$e.max.y-$e.min.y,ti=$e.max.z-$e.min.z,ri=$e.min.x,Ht=$e.min.y,so=$e.min.z):(qt=pn.width,Ut=pn.height,ti=pn.depth,ri=0,Ht=0,so=0),ze!==null?(Yi=ze.x,ao=ze.y,an=ze.z):(Yi=0,ao=0,an=0);const jn=Fe.convert(Le.format),qi=Fe.convert(Le.type);let fi;if(Le.isData3DTexture)JA.setTexture3D(Le,0),fi=uA.TEXTURE_3D;else if(Le.isDataArrayTexture||Le.isCompressedArrayTexture)JA.setTexture2DArray(Le,0),fi=uA.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}uA.pixelStorei(uA.UNPACK_FLIP_Y_WEBGL,Le.flipY),uA.pixelStorei(uA.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Le.premultiplyAlpha),uA.pixelStorei(uA.UNPACK_ALIGNMENT,Le.unpackAlignment);const zo=uA.getParameter(uA.UNPACK_ROW_LENGTH),yi=uA.getParameter(uA.UNPACK_IMAGE_HEIGHT),Qa=uA.getParameter(uA.UNPACK_SKIP_PIXELS),ig=uA.getParameter(uA.UNPACK_SKIP_ROWS),Ms=uA.getParameter(uA.UNPACK_SKIP_IMAGES);uA.pixelStorei(uA.UNPACK_ROW_LENGTH,pn.width),uA.pixelStorei(uA.UNPACK_IMAGE_HEIGHT,pn.height),uA.pixelStorei(uA.UNPACK_SKIP_PIXELS,ri),uA.pixelStorei(uA.UNPACK_SKIP_ROWS,Ht),uA.pixelStorei(uA.UNPACK_SKIP_IMAGES,so),Qe.isDataTexture||Qe.isData3DTexture?uA.texSubImage3D(fi,Je,Yi,ao,an,qt,Ut,ti,jn,qi,pn.data):Le.isCompressedArrayTexture?uA.compressedTexSubImage3D(fi,Je,Yi,ao,an,qt,Ut,ti,jn,pn.data):uA.texSubImage3D(fi,Je,Yi,ao,an,qt,Ut,ti,jn,qi,pn),uA.pixelStorei(uA.UNPACK_ROW_LENGTH,zo),uA.pixelStorei(uA.UNPACK_IMAGE_HEIGHT,yi),uA.pixelStorei(uA.UNPACK_SKIP_PIXELS,Qa),uA.pixelStorei(uA.UNPACK_SKIP_ROWS,ig),uA.pixelStorei(uA.UNPACK_SKIP_IMAGES,Ms),Je===0&&Le.generateMipmaps&&uA.generateMipmap(fi),yA.unbindTexture()},this.initRenderTarget=function(Qe){KA.get(Qe).__webglFramebuffer===void 0&&JA.setupRenderTarget(Qe)},this.initTexture=function(Qe){Qe.isCubeTexture?JA.setTextureCube(Qe,0):Qe.isData3DTexture?JA.setTexture3D(Qe,0):Qe.isDataArrayTexture||Qe.isCompressedArrayTexture?JA.setTexture2DArray(Qe,0):JA.setTexture2D(Qe,0),yA.unbindTexture()},this.resetState=function(){D=0,w=0,x=null,yA.reset(),Xe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return xD}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(A){this._outputColorSpace=A;const e=this.getContext();e.drawingBufferColorSpace=A===yj?"display-p3":"srgb",e.unpackColorSpace=hg.workingColorSpace===eK?"display-p3":"srgb"}}class Pk extends dg{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Np,this.environmentIntensity=1,this.environmentRotation=new Np,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(A,e){return super.copy(A,e),A.background!==null&&(this.background=A.background.clone()),A.environment!==null&&(this.environment=A.environment.clone()),A.fog!==null&&(this.fog=A.fog.clone()),this.backgroundBlurriness=A.backgroundBlurriness,this.backgroundIntensity=A.backgroundIntensity,this.backgroundRotation.copy(A.backgroundRotation),this.environmentIntensity=A.environmentIntensity,this.environmentRotation.copy(A.environmentRotation),A.overrideMaterial!==null&&(this.overrideMaterial=A.overrideMaterial.clone()),this.matrixAutoUpdate=A.matrixAutoUpdate,this}toJSON(A){const e=super.toJSON(A);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class JDe{constructor(A,e){this.isInterleavedBuffer=!0,this.array=A,this.stride=e,this.count=A!==void 0?A.length/e:0,this.usage=mj,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Zy()}onUploadCallback(){}set needsUpdate(A){A===!0&&this.version++}get updateRange(){return Sj("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(A){return this.usage=A,this}addUpdateRange(A,e){this.updateRanges.push({start:A,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(A){return this.array=new A.array.constructor(A.array),this.count=A.count,this.stride=A.stride,this.usage=A.usage,this}copyAt(A,e,i){A*=this.stride,i*=e.stride;for(let o=0,n=this.stride;o<n;o++)this.array[A+o]=e.array[i+o];return this}set(A,e=0){return this.array.set(A,e),this}clone(A){A.arrayBuffers===void 0&&(A.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zy()),A.arrayBuffers[this.array.buffer._uuid]===void 0&&(A.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(A.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(A){return this.onUploadCallback=A,this}toJSON(A){return A.arrayBuffers===void 0&&(A.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zy()),A.arrayBuffers[this.array.buffer._uuid]===void 0&&(A.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const pd=new _e;class iz{constructor(A,e,i,o=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=A,this.itemSize=e,this.offset=i,this.normalized=o}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(A){this.data.needsUpdate=A}applyMatrix4(A){for(let e=0,i=this.data.count;e<i;e++)pd.fromBufferAttribute(this,e),pd.applyMatrix4(A),this.setXYZ(e,pd.x,pd.y,pd.z);return this}applyNormalMatrix(A){for(let e=0,i=this.count;e<i;e++)pd.fromBufferAttribute(this,e),pd.applyNormalMatrix(A),this.setXYZ(e,pd.x,pd.y,pd.z);return this}transformDirection(A){for(let e=0,i=this.count;e<i;e++)pd.fromBufferAttribute(this,e),pd.transformDirection(A),this.setXYZ(e,pd.x,pd.y,pd.z);return this}getComponent(A,e){let i=this.array[A*this.data.stride+this.offset+e];return this.normalized&&(i=Vy(i,this.array)),i}setComponent(A,e,i){return this.normalized&&(i=Eg(i,this.array)),this.data.array[A*this.data.stride+this.offset+e]=i,this}setX(A,e){return this.normalized&&(e=Eg(e,this.array)),this.data.array[A*this.data.stride+this.offset]=e,this}setY(A,e){return this.normalized&&(e=Eg(e,this.array)),this.data.array[A*this.data.stride+this.offset+1]=e,this}setZ(A,e){return this.normalized&&(e=Eg(e,this.array)),this.data.array[A*this.data.stride+this.offset+2]=e,this}setW(A,e){return this.normalized&&(e=Eg(e,this.array)),this.data.array[A*this.data.stride+this.offset+3]=e,this}getX(A){let e=this.data.array[A*this.data.stride+this.offset];return this.normalized&&(e=Vy(e,this.array)),e}getY(A){let e=this.data.array[A*this.data.stride+this.offset+1];return this.normalized&&(e=Vy(e,this.array)),e}getZ(A){let e=this.data.array[A*this.data.stride+this.offset+2];return this.normalized&&(e=Vy(e,this.array)),e}getW(A){let e=this.data.array[A*this.data.stride+this.offset+3];return this.normalized&&(e=Vy(e,this.array)),e}setXY(A,e,i){return A=A*this.data.stride+this.offset,this.normalized&&(e=Eg(e,this.array),i=Eg(i,this.array)),this.data.array[A+0]=e,this.data.array[A+1]=i,this}setXYZ(A,e,i,o){return A=A*this.data.stride+this.offset,this.normalized&&(e=Eg(e,this.array),i=Eg(i,this.array),o=Eg(o,this.array)),this.data.array[A+0]=e,this.data.array[A+1]=i,this.data.array[A+2]=o,this}setXYZW(A,e,i,o,n){return A=A*this.data.stride+this.offset,this.normalized&&(e=Eg(e,this.array),i=Eg(i,this.array),o=Eg(o,this.array),n=Eg(n,this.array)),this.data.array[A+0]=e,this.data.array[A+1]=i,this.data.array[A+2]=o,this.data.array[A+3]=n,this}clone(A){if(A===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const o=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[o+n])}return new cI(new this.array.constructor(e),this.itemSize,this.normalized)}else return A.interleavedBuffers===void 0&&(A.interleavedBuffers={}),A.interleavedBuffers[this.data.uuid]===void 0&&(A.interleavedBuffers[this.data.uuid]=this.data.clone(A)),new iz(A.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(A){if(A===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const o=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[o+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return A.interleavedBuffers===void 0&&(A.interleavedBuffers={}),A.interleavedBuffers[this.data.uuid]===void 0&&(A.interleavedBuffers[this.data.uuid]=this.data.toJSON(A)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const lbA=new _e,QbA=new ug,EbA=new ug,KDe=new _e,hbA=new os,GK=new _e,oz=new Xy,ubA=new os,nz=new N_;class TDe extends on{constructor(A,e){super(A,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=pDA,this.bindMatrix=new os,this.bindMatrixInverse=new os,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const A=this.geometry;this.boundingBox===null&&(this.boundingBox=new jy),this.boundingBox.makeEmpty();const e=A.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,GK),this.boundingBox.expandByPoint(GK)}computeBoundingSphere(){const A=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Xy),this.boundingSphere.makeEmpty();const e=A.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,GK),this.boundingSphere.expandByPoint(GK)}copy(A,e){return super.copy(A,e),this.bindMode=A.bindMode,this.bindMatrix.copy(A.bindMatrix),this.bindMatrixInverse.copy(A.bindMatrixInverse),this.skeleton=A.skeleton,A.boundingBox!==null&&(this.boundingBox=A.boundingBox.clone()),A.boundingSphere!==null&&(this.boundingSphere=A.boundingSphere.clone()),this}raycast(A,e){const i=this.material,o=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),oz.copy(this.boundingSphere),oz.applyMatrix4(o),A.ray.intersectsSphere(oz)!==!1&&(ubA.copy(o).invert(),nz.copy(A.ray).applyMatrix4(ubA),!(this.boundingBox!==null&&nz.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(A,e,nz)))}getVertexPosition(A,e){return super.getVertexPosition(A,e),this.applyBoneTransform(A,e),e}bind(A,e){this.skeleton=A,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const A=new ug,e=this.geometry.attributes.skinWeight;for(let i=0,o=e.count;i<o;i++){A.fromBufferAttribute(e,i);const n=1/A.manhattanLength();n!==1/0?A.multiplyScalar(n):A.set(1,0,0,0),e.setXYZW(i,A.x,A.y,A.z,A.w)}}updateMatrixWorld(A){super.updateMatrixWorld(A),this.bindMode===pDA?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Rfe?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(A,e){const i=this.skeleton,o=this.geometry;QbA.fromBufferAttribute(o.attributes.skinIndex,A),EbA.fromBufferAttribute(o.attributes.skinWeight,A),lbA.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let n=0;n<4;n++){const s=EbA.getComponent(n);if(s!==0){const r=QbA.getComponent(n);hbA.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),e.addScaledVector(KDe.copy(lbA).applyMatrix4(hbA),s)}}return e.applyMatrix4(this.bindMatrixInverse)}}class dbA extends dg{constructor(){super(),this.isBone=!0,this.type="Bone"}}class sz extends Yc{constructor(A=null,e=1,i=1,o,n,s,r,a,g=hu,I=hu,c,B){super(null,s,r,a,g,I,o,n,c,B),this.isDataTexture=!0,this.image={data:A,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const pbA=new os,qDe=new os;class rz{constructor(A=[],e=[]){this.uuid=Zy(),this.bones=A.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const A=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(A.length*16),e.length===0)this.calculateInverses();else if(A.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,o=this.bones.length;i<o;i++)this.boneInverses.push(new os)}}calculateInverses(){this.boneInverses.length=0;for(let A=0,e=this.bones.length;A<e;A++){const i=new os;this.bones[A]&&i.copy(this.bones[A].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let A=0,e=this.bones.length;A<e;A++){const i=this.bones[A];i&&i.matrixWorld.copy(this.boneInverses[A]).invert()}for(let A=0,e=this.bones.length;A<e;A++){const i=this.bones[A];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const A=this.bones,e=this.boneInverses,i=this.boneMatrices,o=this.boneTexture;for(let n=0,s=A.length;n<s;n++){const r=A[n]?A[n].matrixWorld:qDe;pbA.multiplyMatrices(r,e[n]),pbA.toArray(i,n*16)}o!==null&&(o.needsUpdate=!0)}clone(){return new rz(this.bones,this.boneInverses)}computeBoneTexture(){let A=Math.sqrt(this.bones.length*4);A=Math.ceil(A/4)*4,A=Math.max(A,4);const e=new Float32Array(A*A*4);e.set(this.boneMatrices);const i=new sz(e,A,A,Z0,$m);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(A){for(let e=0,i=this.bones.length;e<i;e++){const o=this.bones[e];if(o.name===A)return o}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(A,e){this.uuid=A.uuid;for(let i=0,o=A.bones.length;i<o;i++){const n=A.bones[i];let s=e[n];s===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),s=new dbA),this.bones.push(s),this.boneInverses.push(new os().fromArray(A.boneInverses[i]))}return this.init(),this}toJSON(){const A={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};A.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let o=0,n=e.length;o<n;o++){const s=e[o];A.bones.push(s.uuid);const r=i[o];A.boneInverses.push(r.toArray())}return A}}class FK extends cI{constructor(A,e,i,o=1){super(A,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=o}copy(A){return super.copy(A),this.meshPerAttribute=A.meshPerAttribute,this}toJSON(){const A=super.toJSON();return A.meshPerAttribute=this.meshPerAttribute,A.isInstancedBufferAttribute=!0,A}}const j_=new os,fbA=new os,_K=[],ybA=new jy,PDe=new os,F1=new on,_1=new Xy;class ODe extends on{constructor(A,e,i){super(A,e),this.isInstancedMesh=!0,this.instanceMatrix=new FK(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let o=0;o<i;o++)this.setMatrixAt(o,PDe)}computeBoundingBox(){const A=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new jy),A.boundingBox===null&&A.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,j_),ybA.copy(A.boundingBox).applyMatrix4(j_),this.boundingBox.union(ybA)}computeBoundingSphere(){const A=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Xy),A.boundingSphere===null&&A.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,j_),_1.copy(A.boundingSphere).applyMatrix4(j_),this.boundingSphere.union(_1)}copy(A,e){return super.copy(A,e),this.instanceMatrix.copy(A.instanceMatrix),A.morphTexture!==null&&(this.morphTexture=A.morphTexture.clone()),A.instanceColor!==null&&(this.instanceColor=A.instanceColor.clone()),this.count=A.count,A.boundingBox!==null&&(this.boundingBox=A.boundingBox.clone()),A.boundingSphere!==null&&(this.boundingSphere=A.boundingSphere.clone()),this}getColorAt(A,e){e.fromArray(this.instanceColor.array,A*3)}getMatrixAt(A,e){e.fromArray(this.instanceMatrix.array,A*16)}getMorphAt(A,e){const i=e.morphTargetInfluences,o=this.morphTexture.source.data.data,n=i.length+1,s=A*n+1;for(let r=0;r<i.length;r++)i[r]=o[s+r]}raycast(A,e){const i=this.matrixWorld,o=this.count;if(F1.geometry=this.geometry,F1.material=this.material,F1.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),_1.copy(this.boundingSphere),_1.applyMatrix4(i),A.ray.intersectsSphere(_1)!==!1))for(let n=0;n<o;n++){this.getMatrixAt(n,j_),fbA.multiplyMatrices(i,j_),F1.matrixWorld=fbA,F1.raycast(A,_K);for(let s=0,r=_K.length;s<r;s++){const a=_K[s];a.instanceId=n,a.object=this,e.push(a)}_K.length=0}}setColorAt(A,e){this.instanceColor===null&&(this.instanceColor=new FK(new Float32Array(this.instanceMatrix.count*3),3)),e.toArray(this.instanceColor.array,A*3)}setMatrixAt(A,e){e.toArray(this.instanceMatrix.array,A*16)}setMorphAt(A,e){const i=e.morphTargetInfluences,o=i.length+1;this.morphTexture===null&&(this.morphTexture=new sz(new Float32Array(o*this.count),o,this.count,DDA,$m));const n=this.morphTexture.source.data.data;let s=0;for(let g=0;g<i.length;g++)s+=i[g];const r=this.geometry.morphTargetsRelative?1:1-s,a=o*A;n[a]=r,n.set(i,a+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class Ok extends Mp{constructor(A){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Li(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.color.copy(A.color),this.map=A.map,this.linewidth=A.linewidth,this.linecap=A.linecap,this.linejoin=A.linejoin,this.fog=A.fog,this}}const RK=new _e,NK=new _e,mbA=new os,R1=new N_,MK=new Xy,az=new _e,wbA=new _e;let gz=class extends dg{constructor(A=new Hg,e=new Ok){super(),this.isLine=!0,this.type="Line",this.geometry=A,this.material=e,this.updateMorphTargets()}copy(A,e){return super.copy(A,e),this.material=Array.isArray(A.material)?A.material.slice():A.material,this.geometry=A.geometry,this}computeLineDistances(){const A=this.geometry;if(A.index===null){const e=A.attributes.position,i=[0];for(let o=1,n=e.count;o<n;o++)RK.fromBufferAttribute(e,o-1),NK.fromBufferAttribute(e,o),i[o]=i[o-1],i[o]+=RK.distanceTo(NK);A.setAttribute("lineDistance",new ns(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(A,e){const i=this.geometry,o=this.matrixWorld,n=A.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),MK.copy(i.boundingSphere),MK.applyMatrix4(o),MK.radius+=n,A.ray.intersectsSphere(MK)===!1)return;mbA.copy(o).invert(),R1.copy(A.ray).applyMatrix4(mbA);const r=n/((this.scale.x+this.scale.y+this.scale.z)/3),a=r*r,g=this.isLineSegments?2:1,I=i.index,B=i.attributes.position;if(I!==null){const C=Math.max(0,s.start),l=Math.min(I.count,s.start+s.count);for(let Q=C,E=l-1;Q<E;Q+=g){const h=I.getX(Q),u=I.getX(Q+1),d=vK(this,A,R1,a,h,u);d&&e.push(d)}if(this.isLineLoop){const Q=I.getX(l-1),E=I.getX(C),h=vK(this,A,R1,a,Q,E);h&&e.push(h)}}else{const C=Math.max(0,s.start),l=Math.min(B.count,s.start+s.count);for(let Q=C,E=l-1;Q<E;Q+=g){const h=vK(this,A,R1,a,Q,Q+1);h&&e.push(h)}if(this.isLineLoop){const Q=vK(this,A,R1,a,l-1,C);Q&&e.push(Q)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const o=e[i[0]];if(o!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,s=o.length;n<s;n++){const r=o[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=n}}}}};function vK(t,A,e,i,o,n){const s=t.geometry.attributes.position;if(RK.fromBufferAttribute(s,o),NK.fromBufferAttribute(s,n),e.distanceSqToSegment(RK,NK,az,wbA)>i)return;az.applyMatrix4(t.matrixWorld);const a=A.ray.origin.distanceTo(az);if(!(a<A.near||a>A.far))return{distance:a,point:wbA.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,object:t}}const DbA=new _e,SbA=new _e;class N1 extends gz{constructor(A,e){super(A,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const A=this.geometry;if(A.index===null){const e=A.attributes.position,i=[];for(let o=0,n=e.count;o<n;o+=2)DbA.fromBufferAttribute(e,o),SbA.fromBufferAttribute(e,o+1),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+DbA.distanceTo(SbA);A.setAttribute("lineDistance",new ns(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class WDe extends gz{constructor(A,e){super(A,e),this.isLineLoop=!0,this.type="LineLoop"}}class Wk extends Mp{constructor(A){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Li(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.color.copy(A.color),this.map=A.map,this.alphaMap=A.alphaMap,this.size=A.size,this.sizeAttenuation=A.sizeAttenuation,this.fog=A.fog,this}}const bbA=new os,Iz=new N_,UK=new Xy,LK=new _e;class M1 extends dg{constructor(A=new Hg,e=new Wk){super(),this.isPoints=!0,this.type="Points",this.geometry=A,this.material=e,this.updateMorphTargets()}copy(A,e){return super.copy(A,e),this.material=Array.isArray(A.material)?A.material.slice():A.material,this.geometry=A.geometry,this}raycast(A,e){const i=this.geometry,o=this.matrixWorld,n=A.params.Points.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),UK.copy(i.boundingSphere),UK.applyMatrix4(o),UK.radius+=n,A.ray.intersectsSphere(UK)===!1)return;bbA.copy(o).invert(),Iz.copy(A.ray).applyMatrix4(bbA);const r=n/((this.scale.x+this.scale.y+this.scale.z)/3),a=r*r,g=i.index,c=i.attributes.position;if(g!==null){const B=Math.max(0,s.start),C=Math.min(g.count,s.start+s.count);for(let l=B,Q=C;l<Q;l++){const E=g.getX(l);LK.fromBufferAttribute(c,E),xbA(LK,E,a,o,A,e,this)}}else{const B=Math.max(0,s.start),C=Math.min(c.count,s.start+s.count);for(let l=B,Q=C;l<Q;l++)LK.fromBufferAttribute(c,l),xbA(LK,l,a,o,A,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const o=e[i[0]];if(o!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,s=o.length;n<s;n++){const r=o[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=n}}}}}function xbA(t,A,e,i,o,n,s){const r=Iz.distanceSqToPoint(t);if(r<e){const a=new _e;Iz.closestPointToPoint(t,a),a.applyMatrix4(i);const g=o.ray.origin.distanceTo(a);if(g<o.near||g>o.far)return;n.push({distance:g,distanceToRay:Math.sqrt(r),point:a,index:A,face:null,object:s})}}class cz extends Yc{constructor(A,e,i,o,n,s,r,a,g,I,c,B){super(null,s,r,a,g,I,o,n,c,B),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=A,this.flipY=!1,this.generateMipmaps=!1}}class v1 extends Yc{constructor(A,e,i,o,n,s,r,a,g){super(A,e,i,o,n,s,r,a,g),this.isCanvasTexture=!0,this.needsUpdate=!0}}class HK extends Hg{constructor(A=1,e=1,i=1,o=32,n=1,s=!1,r=0,a=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:A,radiusBottom:e,height:i,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:r,thetaLength:a};const g=this;o=Math.floor(o),n=Math.floor(n);const I=[],c=[],B=[],C=[];let l=0;const Q=[],E=i/2;let h=0;u(),s===!1&&(A>0&&d(!0),e>0&&d(!1)),this.setIndex(I),this.setAttribute("position",new ns(c,3)),this.setAttribute("normal",new ns(B,3)),this.setAttribute("uv",new ns(C,2));function u(){const f=new _e,D=new _e;let w=0;const x=(e-A)/i;for(let b=0;b<=n;b++){const F=[],k=b/n,U=k*(e-A)+A;for(let N=0;N<=o;N++){const J=N/o,P=J*a+r,T=Math.sin(P),O=Math.cos(P);D.x=U*T,D.y=-k*i+E,D.z=U*O,c.push(D.x,D.y,D.z),f.set(T,x,O).normalize(),B.push(f.x,f.y,f.z),C.push(J,1-k),F.push(l++)}Q.push(F)}for(let b=0;b<o;b++)for(let F=0;F<n;F++){const k=Q[F][b],U=Q[F+1][b],N=Q[F+1][b+1],J=Q[F][b+1];I.push(k,U,J),I.push(U,N,J),w+=6}g.addGroup(h,w,0),h+=w}function d(f){const D=l,w=new Io,x=new _e;let b=0;const F=f===!0?A:e,k=f===!0?1:-1;for(let N=1;N<=o;N++)c.push(0,E*k,0),B.push(0,k,0),C.push(.5,.5),l++;const U=l;for(let N=0;N<=o;N++){const P=N/o*a+r,T=Math.cos(P),O=Math.sin(P);x.x=F*O,x.y=E*k,x.z=F*T,c.push(x.x,x.y,x.z),B.push(0,k,0),w.x=T*.5+.5,w.y=O*.5*k+.5,C.push(w.x,w.y),l++}for(let N=0;N<o;N++){const J=D+N,P=U+N;f===!0?I.push(P,P+1,J):I.push(P+1,P,J),b+=3}g.addGroup(h,b,f===!0?1:2),h+=b}}copy(A){return super.copy(A),this.parameters=Object.assign({},A.parameters),this}static fromJSON(A){return new HK(A.radiusTop,A.radiusBottom,A.height,A.radialSegments,A.heightSegments,A.openEnded,A.thetaStart,A.thetaLength)}}class Bz extends HK{constructor(A=1,e=1,i=32,o=1,n=!1,s=0,r=Math.PI*2){super(0,A,e,i,o,n,s,r),this.type="ConeGeometry",this.parameters={radius:A,height:e,radialSegments:i,heightSegments:o,openEnded:n,thetaStart:s,thetaLength:r}}static fromJSON(A){return new Bz(A.radius,A.height,A.radialSegments,A.heightSegments,A.openEnded,A.thetaStart,A.thetaLength)}}const YK=new _e,JK=new _e,Cz=new _e,KK=new em;class ZDe extends Hg{constructor(A=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:A,thresholdAngle:e},A!==null){const o=Math.pow(10,4),n=Math.cos(b_*e),s=A.getIndex(),r=A.getAttribute("position"),a=s?s.count:r.count,g=[0,0,0],I=["a","b","c"],c=new Array(3),B={},C=[];for(let l=0;l<a;l+=3){s?(g[0]=s.getX(l),g[1]=s.getX(l+1),g[2]=s.getX(l+2)):(g[0]=l,g[1]=l+1,g[2]=l+2);const{a:Q,b:E,c:h}=KK;if(Q.fromBufferAttribute(r,g[0]),E.fromBufferAttribute(r,g[1]),h.fromBufferAttribute(r,g[2]),KK.getNormal(Cz),c[0]=`${Math.round(Q.x*o)},${Math.round(Q.y*o)},${Math.round(Q.z*o)}`,c[1]=`${Math.round(E.x*o)},${Math.round(E.y*o)},${Math.round(E.z*o)}`,c[2]=`${Math.round(h.x*o)},${Math.round(h.y*o)},${Math.round(h.z*o)}`,!(c[0]===c[1]||c[1]===c[2]||c[2]===c[0]))for(let u=0;u<3;u++){const d=(u+1)%3,f=c[u],D=c[d],w=KK[I[u]],x=KK[I[d]],b=`${f}_${D}`,F=`${D}_${f}`;F in B&&B[F]?(Cz.dot(B[F].normal)<=n&&(C.push(w.x,w.y,w.z),C.push(x.x,x.y,x.z)),B[F]=null):b in B||(B[b]={index0:g[u],index1:g[d],normal:Cz.clone()})}}for(const l in B)if(B[l]){const{index0:Q,index1:E}=B[l];YK.fromBufferAttribute(r,Q),JK.fromBufferAttribute(r,E),C.push(YK.x,YK.y,YK.z),C.push(JK.x,JK.y,JK.z)}this.setAttribute("position",new ns(C,3))}}copy(A){return super.copy(A),this.parameters=Object.assign({},A.parameters),this}}const VDe={triangulate:function(t,A,e=2){const i=A&&A.length,o=i?A[0]*e:t.length;let n=kbA(t,0,o,e,!0);const s=[];if(!n||n.next===n.prev)return s;let r,a,g,I,c,B,C;if(i&&(n=ASe(t,A,n,e)),t.length>80*e){r=g=t[0],a=I=t[1];for(let l=e;l<o;l+=e)c=t[l],B=t[l+1],c<r&&(r=c),B<a&&(a=B),c>g&&(g=c),B>I&&(I=B);C=Math.max(g-r,I-a),C=C!==0?32767/C:0}return U1(n,s,e,r,a,C,0),s}};function kbA(t,A,e,i,o){let n,s;if(o===cSe(t,A,e,i)>0)for(n=A;n<e;n+=i)s=_bA(n,t[n],t[n+1],s);else for(n=e-i;n>=A;n-=i)s=_bA(n,t[n],t[n+1],s);return s&&TK(s,s.next)&&(H1(s),s=s.next),s}function Zk(t,A){if(!t)return t;A||(A=t);let e=t,i;do if(i=!1,!e.steiner&&(TK(e,e.next)||uB(e.prev,e,e.next)===0)){if(H1(e),e=A=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==A);return A}function U1(t,A,e,i,o,n,s){if(!t)return;!s&&n&&nSe(t,i,o,n);let r=t,a,g;for(;t.prev!==t.next;){if(a=t.prev,g=t.next,n?zDe(t,i,o,n):jDe(t)){A.push(a.i/e|0),A.push(t.i/e|0),A.push(g.i/e|0),H1(t),t=g.next,r=g.next;continue}if(t=g,t===r){s?s===1?(t=XDe(Zk(t),A,e),U1(t,A,e,i,o,n,2)):s===2&&$De(t,A,e,i,o,n):U1(Zk(t),A,e,i,o,n,1);break}}}function jDe(t){const A=t.prev,e=t,i=t.next;if(uB(A,e,i)>=0)return!1;const o=A.x,n=e.x,s=i.x,r=A.y,a=e.y,g=i.y,I=o<n?o<s?o:s:n<s?n:s,c=r<a?r<g?r:g:a<g?a:g,B=o>n?o>s?o:s:n>s?n:s,C=r>a?r>g?r:g:a>g?a:g;let l=i.next;for(;l!==A;){if(l.x>=I&&l.x<=B&&l.y>=c&&l.y<=C&&z_(o,r,n,a,s,g,l.x,l.y)&&uB(l.prev,l,l.next)>=0)return!1;l=l.next}return!0}function zDe(t,A,e,i){const o=t.prev,n=t,s=t.next;if(uB(o,n,s)>=0)return!1;const r=o.x,a=n.x,g=s.x,I=o.y,c=n.y,B=s.y,C=r<a?r<g?r:g:a<g?a:g,l=I<c?I<B?I:B:c<B?c:B,Q=r>a?r>g?r:g:a>g?a:g,E=I>c?I>B?I:B:c>B?c:B,h=lz(C,l,A,e,i),u=lz(Q,E,A,e,i);let d=t.prevZ,f=t.nextZ;for(;d&&d.z>=h&&f&&f.z<=u;){if(d.x>=C&&d.x<=Q&&d.y>=l&&d.y<=E&&d!==o&&d!==s&&z_(r,I,a,c,g,B,d.x,d.y)&&uB(d.prev,d,d.next)>=0||(d=d.prevZ,f.x>=C&&f.x<=Q&&f.y>=l&&f.y<=E&&f!==o&&f!==s&&z_(r,I,a,c,g,B,f.x,f.y)&&uB(f.prev,f,f.next)>=0))return!1;f=f.nextZ}for(;d&&d.z>=h;){if(d.x>=C&&d.x<=Q&&d.y>=l&&d.y<=E&&d!==o&&d!==s&&z_(r,I,a,c,g,B,d.x,d.y)&&uB(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=u;){if(f.x>=C&&f.x<=Q&&f.y>=l&&f.y<=E&&f!==o&&f!==s&&z_(r,I,a,c,g,B,f.x,f.y)&&uB(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function XDe(t,A,e){let i=t;do{const o=i.prev,n=i.next.next;!TK(o,n)&&GbA(o,i,i.next,n)&&L1(o,n)&&L1(n,o)&&(A.push(o.i/e|0),A.push(i.i/e|0),A.push(n.i/e|0),H1(i),H1(i.next),i=t=n),i=i.next}while(i!==t);return Zk(i)}function $De(t,A,e,i,o,n){let s=t;do{let r=s.next.next;for(;r!==s.prev;){if(s.i!==r.i&&aSe(s,r)){let a=FbA(s,r);s=Zk(s,s.next),a=Zk(a,a.next),U1(s,A,e,i,o,n,0),U1(a,A,e,i,o,n,0);return}r=r.next}s=s.next}while(s!==t)}function ASe(t,A,e,i){const o=[];let n,s,r,a,g;for(n=0,s=A.length;n<s;n++)r=A[n]*i,a=n<s-1?A[n+1]*i:t.length,g=kbA(t,r,a,i,!1),g===g.next&&(g.steiner=!0),o.push(rSe(g));for(o.sort(eSe),n=0;n<o.length;n++)e=tSe(o[n],e);return e}function eSe(t,A){return t.x-A.x}function tSe(t,A){const e=iSe(t,A);if(!e)return A;const i=FbA(e,t);return Zk(i,i.next),Zk(e,e.next)}function iSe(t,A){let e=A,i=-1/0,o;const n=t.x,s=t.y;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){const B=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(B<=n&&B>i&&(i=B,o=e.x<e.next.x?e:e.next,B===n))return o}e=e.next}while(e!==A);if(!o)return null;const r=o,a=o.x,g=o.y;let I=1/0,c;e=o;do n>=e.x&&e.x>=a&&n!==e.x&&z_(s<g?n:i,s,a,g,s<g?i:n,s,e.x,e.y)&&(c=Math.abs(s-e.y)/(n-e.x),L1(e,t)&&(c<I||c===I&&(e.x>o.x||e.x===o.x&&oSe(o,e)))&&(o=e,I=c)),e=e.next;while(e!==r);return o}function oSe(t,A){return uB(t.prev,t,A.prev)<0&&uB(A.next,t,t.next)<0}function nSe(t,A,e,i){let o=t;do o.z===0&&(o.z=lz(o.x,o.y,A,e,i)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,sSe(o)}function sSe(t){let A,e,i,o,n,s,r,a,g=1;do{for(e=t,t=null,n=null,s=0;e;){for(s++,i=e,r=0,A=0;A<g&&(r++,i=i.nextZ,!!i);A++);for(a=g;r>0||a>0&&i;)r!==0&&(a===0||!i||e.z<=i.z)?(o=e,e=e.nextZ,r--):(o=i,i=i.nextZ,a--),n?n.nextZ=o:t=o,o.prevZ=n,n=o;e=i}n.nextZ=null,g*=2}while(s>1);return t}function lz(t,A,e,i,o){return t=(t-e)*o|0,A=(A-i)*o|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,A=(A|A<<8)&16711935,A=(A|A<<4)&252645135,A=(A|A<<2)&858993459,A=(A|A<<1)&1431655765,t|A<<1}function rSe(t){let A=t,e=t;do(A.x<e.x||A.x===e.x&&A.y<e.y)&&(e=A),A=A.next;while(A!==t);return e}function z_(t,A,e,i,o,n,s,r){return(o-s)*(A-r)>=(t-s)*(n-r)&&(t-s)*(i-r)>=(e-s)*(A-r)&&(e-s)*(n-r)>=(o-s)*(i-r)}function aSe(t,A){return t.next.i!==A.i&&t.prev.i!==A.i&&!gSe(t,A)&&(L1(t,A)&&L1(A,t)&&ISe(t,A)&&(uB(t.prev,t,A.prev)||uB(t,A.prev,A))||TK(t,A)&&uB(t.prev,t,t.next)>0&&uB(A.prev,A,A.next)>0)}function uB(t,A,e){return(A.y-t.y)*(e.x-A.x)-(A.x-t.x)*(e.y-A.y)}function TK(t,A){return t.x===A.x&&t.y===A.y}function GbA(t,A,e,i){const o=PK(uB(t,A,e)),n=PK(uB(t,A,i)),s=PK(uB(e,i,t)),r=PK(uB(e,i,A));return!!(o!==n&&s!==r||o===0&&qK(t,e,A)||n===0&&qK(t,i,A)||s===0&&qK(e,t,i)||r===0&&qK(e,A,i))}function qK(t,A,e){return A.x<=Math.max(t.x,e.x)&&A.x>=Math.min(t.x,e.x)&&A.y<=Math.max(t.y,e.y)&&A.y>=Math.min(t.y,e.y)}function PK(t){return t>0?1:t<0?-1:0}function gSe(t,A){let e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==A.i&&e.next.i!==A.i&&GbA(e,e.next,t,A))return!0;e=e.next}while(e!==t);return!1}function L1(t,A){return uB(t.prev,t,t.next)<0?uB(t,A,t.next)>=0&&uB(t,t.prev,A)>=0:uB(t,A,t.prev)<0||uB(t,t.next,A)<0}function ISe(t,A){let e=t,i=!1;const o=(t.x+A.x)/2,n=(t.y+A.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&o<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==t);return i}function FbA(t,A){const e=new Qz(t.i,t.x,t.y),i=new Qz(A.i,A.x,A.y),o=t.next,n=A.prev;return t.next=A,A.prev=t,e.next=o,o.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function _bA(t,A,e,i){const o=new Qz(t,A,e);return i?(o.next=i.next,o.prev=i,i.next.prev=o,i.next=o):(o.prev=o,o.next=o),o}function H1(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Qz(t,A,e){this.i=t,this.x=A,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function cSe(t,A,e,i){let o=0;for(let n=A,s=e-i;n<e;n+=i)o+=(t[s]-t[n])*(t[n+1]+t[s+1]),s=n;return o}class Ez{static area(A){const e=A.length;let i=0;for(let o=e-1,n=0;n<e;o=n++)i+=A[o].x*A[n].y-A[n].x*A[o].y;return i*.5}static isClockWise(A){return Ez.area(A)<0}static triangulateShape(A,e){const i=[],o=[],n=[];RbA(A),NbA(i,A);let s=A.length;e.forEach(RbA);for(let a=0;a<e.length;a++)o.push(s),s+=e[a].length,NbA(i,e[a]);const r=VDe.triangulate(i,o);for(let a=0;a<r.length;a+=3)n.push(r.slice(a,a+3));return n}}function RbA(t){const A=t.length;A>2&&t[A-1].equals(t[0])&&t.pop()}function NbA(t,A){for(let e=0;e<A.length;e++)t.push(A[e].x),t.push(A[e].y)}class Y1 extends Hg{constructor(A=1,e=32,i=16,o=0,n=Math.PI*2,s=0,r=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:A,widthSegments:e,heightSegments:i,phiStart:o,phiLength:n,thetaStart:s,thetaLength:r},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const a=Math.min(s+r,Math.PI);let g=0;const I=[],c=new _e,B=new _e,C=[],l=[],Q=[],E=[];for(let h=0;h<=i;h++){const u=[],d=h/i;let f=0;h===0&&s===0?f=.5/e:h===i&&a===Math.PI&&(f=-.5/e);for(let D=0;D<=e;D++){const w=D/e;c.x=-A*Math.cos(o+w*n)*Math.sin(s+d*r),c.y=A*Math.cos(s+d*r),c.z=A*Math.sin(o+w*n)*Math.sin(s+d*r),l.push(c.x,c.y,c.z),B.copy(c).normalize(),Q.push(B.x,B.y,B.z),E.push(w+f,1-d),u.push(g++)}I.push(u)}for(let h=0;h<i;h++)for(let u=0;u<e;u++){const d=I[h][u+1],f=I[h][u],D=I[h+1][u],w=I[h+1][u+1];(h!==0||s>0)&&C.push(d,f,w),(h!==i-1||a<Math.PI)&&C.push(f,D,w)}this.setIndex(C),this.setAttribute("position",new ns(l,3)),this.setAttribute("normal",new ns(Q,3)),this.setAttribute("uv",new ns(E,2))}copy(A){return super.copy(A),this.parameters=Object.assign({},A.parameters),this}static fromJSON(A){return new Y1(A.radius,A.widthSegments,A.heightSegments,A.phiStart,A.phiLength,A.thetaStart,A.thetaLength)}}class pu extends Mp{constructor(A){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Li(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Li(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fj,this.normalScale=new Io(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Np,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.defines={STANDARD:""},this.color.copy(A.color),this.roughness=A.roughness,this.metalness=A.metalness,this.map=A.map,this.lightMap=A.lightMap,this.lightMapIntensity=A.lightMapIntensity,this.aoMap=A.aoMap,this.aoMapIntensity=A.aoMapIntensity,this.emissive.copy(A.emissive),this.emissiveMap=A.emissiveMap,this.emissiveIntensity=A.emissiveIntensity,this.bumpMap=A.bumpMap,this.bumpScale=A.bumpScale,this.normalMap=A.normalMap,this.normalMapType=A.normalMapType,this.normalScale.copy(A.normalScale),this.displacementMap=A.displacementMap,this.displacementScale=A.displacementScale,this.displacementBias=A.displacementBias,this.roughnessMap=A.roughnessMap,this.metalnessMap=A.metalnessMap,this.alphaMap=A.alphaMap,this.envMap=A.envMap,this.envMapRotation.copy(A.envMapRotation),this.envMapIntensity=A.envMapIntensity,this.wireframe=A.wireframe,this.wireframeLinewidth=A.wireframeLinewidth,this.wireframeLinecap=A.wireframeLinecap,this.wireframeLinejoin=A.wireframeLinejoin,this.flatShading=A.flatShading,this.fog=A.fog,this}}class om extends pu{constructor(A){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Io(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ah(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Li(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Li(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Li(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(A)}get anisotropy(){return this._anisotropy}set anisotropy(A){this._anisotropy>0!=A>0&&this.version++,this._anisotropy=A}get clearcoat(){return this._clearcoat}set clearcoat(A){this._clearcoat>0!=A>0&&this.version++,this._clearcoat=A}get iridescence(){return this._iridescence}set iridescence(A){this._iridescence>0!=A>0&&this.version++,this._iridescence=A}get dispersion(){return this._dispersion}set dispersion(A){this._dispersion>0!=A>0&&this.version++,this._dispersion=A}get sheen(){return this._sheen}set sheen(A){this._sheen>0!=A>0&&this.version++,this._sheen=A}get transmission(){return this._transmission}set transmission(A){this._transmission>0!=A>0&&this.version++,this._transmission=A}copy(A){return super.copy(A),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=A.anisotropy,this.anisotropyRotation=A.anisotropyRotation,this.anisotropyMap=A.anisotropyMap,this.clearcoat=A.clearcoat,this.clearcoatMap=A.clearcoatMap,this.clearcoatRoughness=A.clearcoatRoughness,this.clearcoatRoughnessMap=A.clearcoatRoughnessMap,this.clearcoatNormalMap=A.clearcoatNormalMap,this.clearcoatNormalScale.copy(A.clearcoatNormalScale),this.dispersion=A.dispersion,this.ior=A.ior,this.iridescence=A.iridescence,this.iridescenceMap=A.iridescenceMap,this.iridescenceIOR=A.iridescenceIOR,this.iridescenceThicknessRange=[...A.iridescenceThicknessRange],this.iridescenceThicknessMap=A.iridescenceThicknessMap,this.sheen=A.sheen,this.sheenColor.copy(A.sheenColor),this.sheenColorMap=A.sheenColorMap,this.sheenRoughness=A.sheenRoughness,this.sheenRoughnessMap=A.sheenRoughnessMap,this.transmission=A.transmission,this.transmissionMap=A.transmissionMap,this.thickness=A.thickness,this.thicknessMap=A.thicknessMap,this.attenuationDistance=A.attenuationDistance,this.attenuationColor.copy(A.attenuationColor),this.specularIntensity=A.specularIntensity,this.specularIntensityMap=A.specularIntensityMap,this.specularColor.copy(A.specularColor),this.specularColorMap=A.specularColorMap,this}}class hz extends Mp{constructor(A){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Li(16777215),this.specular=new Li(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Li(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fj,this.normalScale=new Io(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Np,this.combine=cj,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.color.copy(A.color),this.specular.copy(A.specular),this.shininess=A.shininess,this.map=A.map,this.lightMap=A.lightMap,this.lightMapIntensity=A.lightMapIntensity,this.aoMap=A.aoMap,this.aoMapIntensity=A.aoMapIntensity,this.emissive.copy(A.emissive),this.emissiveMap=A.emissiveMap,this.emissiveIntensity=A.emissiveIntensity,this.bumpMap=A.bumpMap,this.bumpScale=A.bumpScale,this.normalMap=A.normalMap,this.normalMapType=A.normalMapType,this.normalScale.copy(A.normalScale),this.displacementMap=A.displacementMap,this.displacementScale=A.displacementScale,this.displacementBias=A.displacementBias,this.specularMap=A.specularMap,this.alphaMap=A.alphaMap,this.envMap=A.envMap,this.envMapRotation.copy(A.envMapRotation),this.combine=A.combine,this.reflectivity=A.reflectivity,this.refractionRatio=A.refractionRatio,this.wireframe=A.wireframe,this.wireframeLinewidth=A.wireframeLinewidth,this.wireframeLinecap=A.wireframeLinecap,this.wireframeLinejoin=A.wireframeLinejoin,this.flatShading=A.flatShading,this.fog=A.fog,this}}function OK(t,A,e){return!t||!e&&t.constructor===A?t:typeof A.BYTES_PER_ELEMENT=="number"?new A(t):Array.prototype.slice.call(t)}function BSe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function CSe(t){function A(o,n){return t[o]-t[n]}const e=t.length,i=new Array(e);for(let o=0;o!==e;++o)i[o]=o;return i.sort(A),i}function MbA(t,A,e){const i=t.length,o=new t.constructor(i);for(let n=0,s=0;s!==i;++n){const r=e[n]*A;for(let a=0;a!==A;++a)o[s++]=t[r+a]}return o}function vbA(t,A,e,i){let o=1,n=t[0];for(;n!==void 0&&n[i]===void 0;)n=t[o++];if(n===void 0)return;let s=n[i];if(s!==void 0)if(Array.isArray(s))do s=n[i],s!==void 0&&(A.push(n.time),e.push.apply(e,s)),n=t[o++];while(n!==void 0);else if(s.toArray!==void 0)do s=n[i],s!==void 0&&(A.push(n.time),s.toArray(e,e.length)),n=t[o++];while(n!==void 0);else do s=n[i],s!==void 0&&(A.push(n.time),e.push(s)),n=t[o++];while(n!==void 0)}class J1{constructor(A,e,i,o){this.parameterPositions=A,this._cachedIndex=0,this.resultBuffer=o!==void 0?o:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(A){const e=this.parameterPositions;let i=this._cachedIndex,o=e[i],n=e[i-1];A:{e:{let s;t:{i:if(!(A<o)){for(let r=i+2;;){if(o===void 0){if(A<n)break i;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===r)break;if(n=o,o=e[++i],A<o)break e}s=e.length;break t}if(!(A>=n)){const r=e[1];A<r&&(i=2,n=r);for(let a=i-2;;){if(n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===a)break;if(o=n,n=e[--i-1],A>=n)break e}s=i,i=0;break t}break A}for(;i<s;){const r=i+s>>>1;A<e[r]?s=r:i=r+1}if(o=e[i],n=e[i-1],n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(o===void 0)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,n,o)}return this.interpolate_(i,n,A,o)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(A){const e=this.resultBuffer,i=this.sampleValues,o=this.valueSize,n=A*o;for(let s=0;s!==o;++s)e[s]=i[n+s];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class lSe extends J1{constructor(A,e,i,o){super(A,e,i,o),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:eSA,endingEnd:eSA}}intervalChanged_(A,e,i){const o=this.parameterPositions;let n=A-2,s=A+1,r=o[n],a=o[s];if(r===void 0)switch(this.getSettings_().endingStart){case tSA:n=A,r=2*e-i;break;case iSA:n=o.length-2,r=e+o[n]-o[n+1];break;default:n=A,r=i}if(a===void 0)switch(this.getSettings_().endingEnd){case tSA:s=A,a=2*i-e;break;case iSA:s=1,a=i+o[1]-o[0];break;default:s=A-1,a=e}const g=(i-e)*.5,I=this.valueSize;this._weightPrev=g/(e-r),this._weightNext=g/(a-i),this._offsetPrev=n*I,this._offsetNext=s*I}interpolate_(A,e,i,o){const n=this.resultBuffer,s=this.sampleValues,r=this.valueSize,a=A*r,g=a-r,I=this._offsetPrev,c=this._offsetNext,B=this._weightPrev,C=this._weightNext,l=(i-e)/(o-e),Q=l*l,E=Q*l,h=-B*E+2*B*Q-B*l,u=(1+B)*E+(-1.5-2*B)*Q+(-.5+B)*l+1,d=(-1-C)*E+(1.5+C)*Q+.5*l,f=C*E-C*Q;for(let D=0;D!==r;++D)n[D]=h*s[I+D]+u*s[g+D]+d*s[a+D]+f*s[c+D];return n}}class QSe extends J1{constructor(A,e,i,o){super(A,e,i,o)}interpolate_(A,e,i,o){const n=this.resultBuffer,s=this.sampleValues,r=this.valueSize,a=A*r,g=a-r,I=(i-e)/(o-e),c=1-I;for(let B=0;B!==r;++B)n[B]=s[g+B]*c+s[a+B]*I;return n}}class ESe extends J1{constructor(A,e,i,o){super(A,e,i,o)}interpolate_(A){return this.copySampleValue_(A-1)}}class tw{constructor(A,e,i,o){if(A===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+A);this.name=A,this.times=OK(e,this.TimeBufferType),this.values=OK(i,this.ValueBufferType),this.setInterpolation(o||this.DefaultInterpolation)}static toJSON(A){const e=A.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(A);else{i={name:A.name,times:OK(A.times,Array),values:OK(A.values,Array)};const o=A.getInterpolation();o!==A.DefaultInterpolation&&(i.interpolation=o)}return i.type=A.ValueTypeName,i}InterpolantFactoryMethodDiscrete(A){return new ESe(this.times,this.values,this.getValueSize(),A)}InterpolantFactoryMethodLinear(A){return new QSe(this.times,this.values,this.getValueSize(),A)}InterpolantFactoryMethodSmooth(A){return new lSe(this.times,this.values,this.getValueSize(),A)}setInterpolation(A){let e;switch(A){case w_:e=this.InterpolantFactoryMethodDiscrete;break;case D_:e=this.InterpolantFactoryMethodLinear;break;case dj:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(A!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return w_;case this.InterpolantFactoryMethodLinear:return D_;case this.InterpolantFactoryMethodSmooth:return dj}}getValueSize(){return this.values.length/this.times.length}shift(A){if(A!==0){const e=this.times;for(let i=0,o=e.length;i!==o;++i)e[i]+=A}return this}scale(A){if(A!==1){const e=this.times;for(let i=0,o=e.length;i!==o;++i)e[i]*=A}return this}trim(A,e){const i=this.times,o=i.length;let n=0,s=o-1;for(;n!==o&&i[n]<A;)++n;for(;s!==-1&&i[s]>e;)--s;if(++s,n!==0||s!==o){n>=s&&(s=Math.max(s,1),n=s-1);const r=this.getValueSize();this.times=i.slice(n,s),this.values=this.values.slice(n*r,s*r)}return this}validate(){let A=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),A=!1);const i=this.times,o=this.values,n=i.length;n===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),A=!1);let s=null;for(let r=0;r!==n;r++){const a=i[r];if(typeof a=="number"&&isNaN(a)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,r,a),A=!1;break}if(s!==null&&s>a){console.error("THREE.KeyframeTrack: Out of order keys.",this,r,a,s),A=!1;break}s=a}if(o!==void 0&&BSe(o))for(let r=0,a=o.length;r!==a;++r){const g=o[r];if(isNaN(g)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,r,g),A=!1;break}}return A}optimize(){const A=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),o=this.getInterpolation()===dj,n=A.length-1;let s=1;for(let r=1;r<n;++r){let a=!1;const g=A[r],I=A[r+1];if(g!==I&&(r!==1||g!==A[0]))if(o)a=!0;else{const c=r*i,B=c-i,C=c+i;for(let l=0;l!==i;++l){const Q=e[c+l];if(Q!==e[B+l]||Q!==e[C+l]){a=!0;break}}}if(a){if(r!==s){A[s]=A[r];const c=r*i,B=s*i;for(let C=0;C!==i;++C)e[B+C]=e[c+C]}++s}}if(n>0){A[s]=A[n];for(let r=n*i,a=s*i,g=0;g!==i;++g)e[a+g]=e[r+g];++s}return s!==A.length?(this.times=A.slice(0,s),this.values=e.slice(0,s*i)):(this.times=A,this.values=e),this}clone(){const A=this.times.slice(),e=this.values.slice(),i=this.constructor,o=new i(this.name,A,e);return o.createInterpolant=this.createInterpolant,o}}tw.prototype.TimeBufferType=Float32Array,tw.prototype.ValueBufferType=Float32Array,tw.prototype.DefaultInterpolation=D_;class X_ extends tw{constructor(A,e,i){super(A,e,i)}}X_.prototype.ValueTypeName="bool",X_.prototype.ValueBufferType=Array,X_.prototype.DefaultInterpolation=w_,X_.prototype.InterpolantFactoryMethodLinear=void 0,X_.prototype.InterpolantFactoryMethodSmooth=void 0;class UbA extends tw{}UbA.prototype.ValueTypeName="color";class $_ extends tw{}$_.prototype.ValueTypeName="number";class hSe extends J1{constructor(A,e,i,o){super(A,e,i,o)}interpolate_(A,e,i,o){const n=this.resultBuffer,s=this.sampleValues,r=this.valueSize,a=(i-e)/(o-e);let g=A*r;for(let I=g+r;g!==I;g+=4)hd.slerpFlat(n,0,s,g-r,s,g,a);return n}}class AR extends tw{InterpolantFactoryMethodLinear(A){return new hSe(this.times,this.values,this.getValueSize(),A)}}AR.prototype.ValueTypeName="quaternion",AR.prototype.InterpolantFactoryMethodSmooth=void 0;class eR extends tw{constructor(A,e,i){super(A,e,i)}}eR.prototype.ValueTypeName="string",eR.prototype.ValueBufferType=Array,eR.prototype.DefaultInterpolation=w_,eR.prototype.InterpolantFactoryMethodLinear=void 0,eR.prototype.InterpolantFactoryMethodSmooth=void 0;class tR extends tw{}tR.prototype.ValueTypeName="vector";class uSe{constructor(A="",e=-1,i=[],o=Tfe){this.name=A,this.tracks=i,this.duration=e,this.blendMode=o,this.uuid=Zy(),this.duration<0&&this.resetDuration()}static parse(A){const e=[],i=A.tracks,o=1/(A.fps||1);for(let s=0,r=i.length;s!==r;++s)e.push(pSe(i[s]).scale(o));const n=new this(A.name,A.duration,e,A.blendMode);return n.uuid=A.uuid,n}static toJSON(A){const e=[],i=A.tracks,o={name:A.name,duration:A.duration,tracks:e,uuid:A.uuid,blendMode:A.blendMode};for(let n=0,s=i.length;n!==s;++n)e.push(tw.toJSON(i[n]));return o}static CreateFromMorphTargetSequence(A,e,i,o){const n=e.length,s=[];for(let r=0;r<n;r++){let a=[],g=[];a.push((r+n-1)%n,r,(r+1)%n),g.push(0,1,0);const I=CSe(a);a=MbA(a,1,I),g=MbA(g,1,I),!o&&a[0]===0&&(a.push(n),g.push(g[0])),s.push(new $_(".morphTargetInfluences["+e[r].name+"]",a,g).scale(1/i))}return new this(A,-1,s)}static findByName(A,e){let i=A;if(!Array.isArray(A)){const o=A;i=o.geometry&&o.geometry.animations||o.animations}for(let o=0;o<i.length;o++)if(i[o].name===e)return i[o];return null}static CreateClipsFromMorphTargetSequences(A,e,i){const o={},n=/^([\w-]*?)([\d]+)$/;for(let r=0,a=A.length;r<a;r++){const g=A[r],I=g.name.match(n);if(I&&I.length>1){const c=I[1];let B=o[c];B||(o[c]=B=[]),B.push(g)}}const s=[];for(const r in o)s.push(this.CreateFromMorphTargetSequence(r,o[r],e,i));return s}static parseAnimation(A,e){if(!A)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(c,B,C,l,Q){if(C.length!==0){const E=[],h=[];vbA(C,E,h,l),E.length!==0&&Q.push(new c(B,E,h))}},o=[],n=A.name||"default",s=A.fps||30,r=A.blendMode;let a=A.length||-1;const g=A.hierarchy||[];for(let c=0;c<g.length;c++){const B=g[c].keys;if(!(!B||B.length===0))if(B[0].morphTargets){const C={};let l;for(l=0;l<B.length;l++)if(B[l].morphTargets)for(let Q=0;Q<B[l].morphTargets.length;Q++)C[B[l].morphTargets[Q]]=-1;for(const Q in C){const E=[],h=[];for(let u=0;u!==B[l].morphTargets.length;++u){const d=B[l];E.push(d.time),h.push(d.morphTarget===Q?1:0)}o.push(new $_(".morphTargetInfluence["+Q+"]",E,h))}a=C.length*s}else{const C=".bones["+e[c].name+"]";i(tR,C+".position",B,"pos",o),i(AR,C+".quaternion",B,"rot",o),i(tR,C+".scale",B,"scl",o)}}return o.length===0?null:new this(n,a,o,r)}resetDuration(){const A=this.tracks;let e=0;for(let i=0,o=A.length;i!==o;++i){const n=this.tracks[i];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let A=0;A<this.tracks.length;A++)this.tracks[A].trim(0,this.duration);return this}validate(){let A=!0;for(let e=0;e<this.tracks.length;e++)A=A&&this.tracks[e].validate();return A}optimize(){for(let A=0;A<this.tracks.length;A++)this.tracks[A].optimize();return this}clone(){const A=[];for(let e=0;e<this.tracks.length;e++)A.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,A,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function dSe(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return $_;case"vector":case"vector2":case"vector3":case"vector4":return tR;case"color":return UbA;case"quaternion":return AR;case"bool":case"boolean":return X_;case"string":return eR}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}function pSe(t){if(t.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const A=dSe(t.type);if(t.times===void 0){const e=[],i=[];vbA(t.keys,e,i,"value"),t.times=e,t.values=i}return A.parse!==void 0?A.parse(t):new A(t.name,t.times,t.values,t.interpolation)}const Db={enabled:!1,files:{},add:function(t,A){this.enabled!==!1&&(this.files[t]=A)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class fSe{constructor(A,e,i){const o=this;let n=!1,s=0,r=0,a;const g=[];this.onStart=void 0,this.onLoad=A,this.onProgress=e,this.onError=i,this.itemStart=function(I){r++,n===!1&&o.onStart!==void 0&&o.onStart(I,s,r),n=!0},this.itemEnd=function(I){s++,o.onProgress!==void 0&&o.onProgress(I,s,r),s===r&&(n=!1,o.onLoad!==void 0&&o.onLoad())},this.itemError=function(I){o.onError!==void 0&&o.onError(I)},this.resolveURL=function(I){return a?a(I):I},this.setURLModifier=function(I){return a=I,this},this.addHandler=function(I,c){return g.push(I,c),this},this.removeHandler=function(I){const c=g.indexOf(I);return c!==-1&&g.splice(c,2),this},this.getHandler=function(I){for(let c=0,B=g.length;c<B;c+=2){const C=g[c],l=g[c+1];if(C.global&&(C.lastIndex=0),C.test(I))return l}return null}}}const LbA=new fSe;class iw{constructor(A){this.manager=A!==void 0?A:LbA,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(A,e){const i=this;return new Promise(function(o,n){i.load(A,o,e,n)})}parse(){}setCrossOrigin(A){return this.crossOrigin=A,this}setWithCredentials(A){return this.withCredentials=A,this}setPath(A){return this.path=A,this}setResourcePath(A){return this.resourcePath=A,this}setRequestHeader(A){return this.requestHeader=A,this}}iw.DEFAULT_MATERIAL_NAME="__DEFAULT";const ND={};class ySe extends Error{constructor(A,e){super(A),this.response=e}}class iR extends iw{constructor(A){super(A)}load(A,e,i,o){A===void 0&&(A=""),this.path!==void 0&&(A=this.path+A),A=this.manager.resolveURL(A);const n=Db.get(A);if(n!==void 0)return this.manager.itemStart(A),setTimeout(()=>{e&&e(n),this.manager.itemEnd(A)},0),n;if(ND[A]!==void 0){ND[A].push({onLoad:e,onProgress:i,onError:o});return}ND[A]=[],ND[A].push({onLoad:e,onProgress:i,onError:o});const s=new Request(A,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),r=this.mimeType,a=this.responseType;fetch(s).then(g=>{if(g.status===200||g.status===0){if(g.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||g.body===void 0||g.body.getReader===void 0)return g;const I=ND[A],c=g.body.getReader(),B=g.headers.get("X-File-Size")||g.headers.get("Content-Length"),C=B?parseInt(B):0,l=C!==0;let Q=0;const E=new ReadableStream({start(h){u();function u(){c.read().then(({done:d,value:f})=>{if(d)h.close();else{Q+=f.byteLength;const D=new ProgressEvent("progress",{lengthComputable:l,loaded:Q,total:C});for(let w=0,x=I.length;w<x;w++){const b=I[w];b.onProgress&&b.onProgress(D)}h.enqueue(f),u()}},d=>{h.error(d)})}}});return new Response(E)}else throw new ySe(`fetch for "${g.url}" responded with ${g.status}: ${g.statusText}`,g)}).then(g=>{switch(a){case"arraybuffer":return g.arrayBuffer();case"blob":return g.blob();case"document":return g.text().then(I=>new DOMParser().parseFromString(I,r));case"json":return g.json();default:if(r===void 0)return g.text();{const c=/charset="?([^;"\s]*)"?/i.exec(r),B=c&&c[1]?c[1].toLowerCase():void 0,C=new TextDecoder(B);return g.arrayBuffer().then(l=>C.decode(l))}}}).then(g=>{Db.add(A,g);const I=ND[A];delete ND[A];for(let c=0,B=I.length;c<B;c++){const C=I[c];C.onLoad&&C.onLoad(g)}}).catch(g=>{const I=ND[A];if(I===void 0)throw this.manager.itemError(A),g;delete ND[A];for(let c=0,B=I.length;c<B;c++){const C=I[c];C.onError&&C.onError(g)}this.manager.itemError(A)}).finally(()=>{this.manager.itemEnd(A)}),this.manager.itemStart(A)}setResponseType(A){return this.responseType=A,this}setMimeType(A){return this.mimeType=A,this}}class mSe extends iw{constructor(A){super(A)}load(A,e,i,o){this.path!==void 0&&(A=this.path+A),A=this.manager.resolveURL(A);const n=this,s=Db.get(A);if(s!==void 0)return n.manager.itemStart(A),setTimeout(function(){e&&e(s),n.manager.itemEnd(A)},0),s;const r=w1("img");function a(){I(),Db.add(A,this),e&&e(this),n.manager.itemEnd(A)}function g(c){I(),o&&o(c),n.manager.itemError(A),n.manager.itemEnd(A)}function I(){r.removeEventListener("load",a,!1),r.removeEventListener("error",g,!1)}return r.addEventListener("load",a,!1),r.addEventListener("error",g,!1),A.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(r.crossOrigin=this.crossOrigin),n.manager.itemStart(A),r.src=A,r}}class uz extends iw{constructor(A){super(A)}load(A,e,i,o){const n=new Yc,s=new mSe(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(A,function(r){n.image=r,n.needsUpdate=!0,e!==void 0&&e(n)},i,o),n}}class WK extends dg{constructor(A,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Li(A),this.intensity=e}dispose(){}copy(A,e){return super.copy(A,e),this.color.copy(A.color),this.intensity=A.intensity,this}toJSON(A){const e=super.toJSON(A);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}}const dz=new os,HbA=new _e,YbA=new _e;class pz{constructor(A){this.camera=A,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Io(512,512),this.map=null,this.mapPass=null,this.matrix=new os,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Oj,this._frameExtents=new Io(1,1),this._viewportCount=1,this._viewports=[new ug(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(A){const e=this.camera,i=this.matrix;HbA.setFromMatrixPosition(A.matrixWorld),e.position.copy(HbA),YbA.setFromMatrixPosition(A.target.matrixWorld),e.lookAt(YbA),e.updateMatrixWorld(),dz.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dz),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(dz)}getViewport(A){return this._viewports[A]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(A){return this.camera=A.camera.clone(),this.bias=A.bias,this.radius=A.radius,this.mapSize.copy(A.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const A={};return this.bias!==0&&(A.bias=this.bias),this.normalBias!==0&&(A.normalBias=this.normalBias),this.radius!==1&&(A.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(A.mapSize=this.mapSize.toArray()),A.camera=this.camera.toJSON(!1).object,delete A.camera.matrix,A}}class wSe extends pz{constructor(){super(new sE(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(A){const e=this.camera,i=x_*2*A.angle*this.focus,o=this.mapSize.width/this.mapSize.height,n=A.distance||e.far;(i!==e.fov||o!==e.aspect||n!==e.far)&&(e.fov=i,e.aspect=o,e.far=n,e.updateProjectionMatrix()),super.updateMatrices(A)}copy(A){return super.copy(A),this.focus=A.focus,this}}class DSe extends WK{constructor(A,e,i=0,o=Math.PI/3,n=0,s=2){super(A,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(dg.DEFAULT_UP),this.updateMatrix(),this.target=new dg,this.distance=i,this.angle=o,this.penumbra=n,this.decay=s,this.map=null,this.shadow=new wSe}get power(){return this.intensity*Math.PI}set power(A){this.intensity=A/Math.PI}dispose(){this.shadow.dispose()}copy(A,e){return super.copy(A,e),this.distance=A.distance,this.angle=A.angle,this.penumbra=A.penumbra,this.decay=A.decay,this.target=A.target.clone(),this.shadow=A.shadow.clone(),this}}const JbA=new os,K1=new _e,fz=new _e;class SSe extends pz{constructor(){super(new sE(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Io(4,2),this._viewportCount=6,this._viewports=[new ug(2,1,1,1),new ug(0,1,1,1),new ug(3,1,1,1),new ug(1,1,1,1),new ug(3,0,1,1),new ug(1,0,1,1)],this._cubeDirections=[new _e(1,0,0),new _e(-1,0,0),new _e(0,0,1),new _e(0,0,-1),new _e(0,1,0),new _e(0,-1,0)],this._cubeUps=[new _e(0,1,0),new _e(0,1,0),new _e(0,1,0),new _e(0,1,0),new _e(0,0,1),new _e(0,0,-1)]}updateMatrices(A,e=0){const i=this.camera,o=this.matrix,n=A.distance||i.far;n!==i.far&&(i.far=n,i.updateProjectionMatrix()),K1.setFromMatrixPosition(A.matrixWorld),i.position.copy(K1),fz.copy(i.position),fz.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(fz),i.updateMatrixWorld(),o.makeTranslation(-K1.x,-K1.y,-K1.z),JbA.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(JbA)}}class yz extends WK{constructor(A,e,i=0,o=2){super(A,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=o,this.shadow=new SSe}get power(){return this.intensity*4*Math.PI}set power(A){this.intensity=A/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(A,e){return super.copy(A,e),this.distance=A.distance,this.decay=A.decay,this.shadow=A.shadow.clone(),this}}class bSe extends pz{constructor(){super(new k1(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class xSe extends WK{constructor(A,e){super(A,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(dg.DEFAULT_UP),this.updateMatrix(),this.target=new dg,this.shadow=new bSe}dispose(){this.shadow.dispose()}copy(A){return super.copy(A),this.target=A.target.clone(),this.shadow=A.shadow.clone(),this}}class KbA extends WK{constructor(A,e){super(A,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Vk{static decodeText(A){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(A);let e="";for(let i=0,o=A.length;i<o;i++)e+=String.fromCharCode(A[i]);try{return decodeURIComponent(escape(e))}catch{return e}}static extractUrlBase(A){const e=A.lastIndexOf("/");return e===-1?"./":A.slice(0,e+1)}static resolveURL(A,e){return typeof A!="string"||A===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(A)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(A)||/^data:.*,.*$/i.test(A)||/^blob:.*$/i.test(A)?A:e+A)}}class kSe extends Hg{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(A){return super.copy(A),this.instanceCount=A.instanceCount,this}toJSON(){const A=super.toJSON();return A.instanceCount=this.instanceCount,A.isInstancedBufferGeometry=!0,A}}class GSe extends iw{constructor(A){super(A),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(A){return this.options=A,this}load(A,e,i,o){A===void 0&&(A=""),this.path!==void 0&&(A=this.path+A),A=this.manager.resolveURL(A);const n=this,s=Db.get(A);if(s!==void 0){if(n.manager.itemStart(A),s.then){s.then(g=>{e&&e(g),n.manager.itemEnd(A)}).catch(g=>{o&&o(g)});return}return setTimeout(function(){e&&e(s),n.manager.itemEnd(A)},0),s}const r={};r.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",r.headers=this.requestHeader;const a=fetch(A,r).then(function(g){return g.blob()}).then(function(g){return createImageBitmap(g,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(g){return Db.add(A,g),e&&e(g),n.manager.itemEnd(A),g}).catch(function(g){o&&o(g),Db.remove(A),n.manager.itemError(A),n.manager.itemEnd(A)});Db.add(A,a),n.manager.itemStart(A)}}class FSe{constructor(A=!0){this.autoStart=A,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=TbA(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let A=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=TbA();A=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=A}return A}}function TbA(){return(typeof performance>"u"?Date:performance).now()}const mz="\\[\\]\\.:\\/",_Se=new RegExp("["+mz+"]","g"),wz="[^"+mz+"]",RSe="[^"+mz.replace("\\.","")+"]",NSe=/((?:WC+[\/:])*)/.source.replace("WC",wz),MSe=/(WCOD+)?/.source.replace("WCOD",RSe),vSe=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",wz),USe=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",wz),LSe=new RegExp("^"+NSe+MSe+vSe+USe+"$"),HSe=["material","materials","bones","map"];class YSe{constructor(A,e,i){const o=i||Ia.parseTrackName(e);this._targetGroup=A,this._bindings=A.subscribe_(e,o)}getValue(A,e){this.bind();const i=this._targetGroup.nCachedObjects_,o=this._bindings[i];o!==void 0&&o.getValue(A,e)}setValue(A,e){const i=this._bindings;for(let o=this._targetGroup.nCachedObjects_,n=i.length;o!==n;++o)i[o].setValue(A,e)}bind(){const A=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=A.length;e!==i;++e)A[e].bind()}unbind(){const A=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=A.length;e!==i;++e)A[e].unbind()}}class Ia{constructor(A,e,i){this.path=e,this.parsedPath=i||Ia.parseTrackName(e),this.node=Ia.findNode(A,this.parsedPath.nodeName),this.rootNode=A,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(A,e,i){return A&&A.isAnimationObjectGroup?new Ia.Composite(A,e,i):new Ia(A,e,i)}static sanitizeNodeName(A){return A.replace(/\s/g,"_").replace(_Se,"")}static parseTrackName(A){const e=LSe.exec(A);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+A);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},o=i.nodeName&&i.nodeName.lastIndexOf(".");if(o!==void 0&&o!==-1){const n=i.nodeName.substring(o+1);HSe.indexOf(n)!==-1&&(i.nodeName=i.nodeName.substring(0,o),i.objectName=n)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+A);return i}static findNode(A,e){if(e===void 0||e===""||e==="."||e===-1||e===A.name||e===A.uuid)return A;if(A.skeleton){const i=A.skeleton.getBoneByName(e);if(i!==void 0)return i}if(A.children){const i=function(n){for(let s=0;s<n.length;s++){const r=n[s];if(r.name===e||r.uuid===e)return r;const a=i(r.children);if(a)return a}return null},o=i(A.children);if(o)return o}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(A,e){A[e]=this.targetObject[this.propertyName]}_getValue_array(A,e){const i=this.resolvedProperty;for(let o=0,n=i.length;o!==n;++o)A[e++]=i[o]}_getValue_arrayElement(A,e){A[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(A,e){this.resolvedProperty.toArray(A,e)}_setValue_direct(A,e){this.targetObject[this.propertyName]=A[e]}_setValue_direct_setNeedsUpdate(A,e){this.targetObject[this.propertyName]=A[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(A,e){this.targetObject[this.propertyName]=A[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(A,e){const i=this.resolvedProperty;for(let o=0,n=i.length;o!==n;++o)i[o]=A[e++]}_setValue_array_setNeedsUpdate(A,e){const i=this.resolvedProperty;for(let o=0,n=i.length;o!==n;++o)i[o]=A[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(A,e){const i=this.resolvedProperty;for(let o=0,n=i.length;o!==n;++o)i[o]=A[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(A,e){this.resolvedProperty[this.propertyIndex]=A[e]}_setValue_arrayElement_setNeedsUpdate(A,e){this.resolvedProperty[this.propertyIndex]=A[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(A,e){this.resolvedProperty[this.propertyIndex]=A[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(A,e){this.resolvedProperty.fromArray(A,e)}_setValue_fromArray_setNeedsUpdate(A,e){this.resolvedProperty.fromArray(A,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(A,e){this.resolvedProperty.fromArray(A,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(A,e){this.bind(),this.getValue(A,e)}_setValue_unbound(A,e){this.bind(),this.setValue(A,e)}bind(){let A=this.node;const e=this.parsedPath,i=e.objectName,o=e.propertyName;let n=e.propertyIndex;if(A||(A=Ia.findNode(this.rootNode,e.nodeName),this.node=A),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!A){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let g=e.objectIndex;switch(i){case"materials":if(!A.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!A.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}A=A.material.materials;break;case"bones":if(!A.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}A=A.skeleton.bones;for(let I=0;I<A.length;I++)if(A[I].name===g){g=I;break}break;case"map":if("map"in A){A=A.map;break}if(!A.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!A.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}A=A.material.map;break;default:if(A[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}A=A[i]}if(g!==void 0){if(A[g]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,A);return}A=A[g]}}const s=A[o];if(s===void 0){const g=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+g+"."+o+" but it wasn't found.",A);return}let r=this.Versioning.None;this.targetObject=A,A.needsUpdate!==void 0?r=this.Versioning.NeedsUpdate:A.matrixWorldNeedsUpdate!==void 0&&(r=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(n!==void 0){if(o==="morphTargetInfluences"){if(!A.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!A.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}A.morphTargetDictionary[n]!==void 0&&(n=A.morphTargetDictionary[n])}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=n}else s.fromArray!==void 0&&s.toArray!==void 0?(a=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(a=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=o;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][r]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Ia.Composite=YSe,Ia.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Ia.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Ia.prototype.GetterByBindingType=[Ia.prototype._getValue_direct,Ia.prototype._getValue_array,Ia.prototype._getValue_arrayElement,Ia.prototype._getValue_toArray],Ia.prototype.SetterByBindingTypeAndVersioning=[[Ia.prototype._setValue_direct,Ia.prototype._setValue_direct_setNeedsUpdate,Ia.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ia.prototype._setValue_array,Ia.prototype._setValue_array_setNeedsUpdate,Ia.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ia.prototype._setValue_arrayElement,Ia.prototype._setValue_arrayElement_setNeedsUpdate,Ia.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ia.prototype._setValue_fromArray,Ia.prototype._setValue_fromArray_setNeedsUpdate,Ia.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Dz{constructor(A){this.value=A}clone(){return new Dz(this.value.clone===void 0?this.value:this.value.clone())}}const qbA=new os;class JSe{constructor(A,e,i=0,o=1/0){this.ray=new N_(A,e),this.near=i,this.far=o,this.camera=null,this.layers=new Mj,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(A,e){this.ray.set(A,e)}setFromCamera(A,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(A.x,A.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(A.x,A.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(A){return qbA.identity().extractRotation(A.matrixWorld),this.ray.origin.setFromMatrixPosition(A.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(qbA),this}intersectObject(A,e=!0,i=[]){return Sz(A,this,i,e),i.sort(PbA),i}intersectObjects(A,e=!0,i=[]){for(let o=0,n=A.length;o<n;o++)Sz(A[o],this,i,e);return i.sort(PbA),i}}function PbA(t,A){return t.distance-A.distance}function Sz(t,A,e,i){let o=!0;if(t.layers.test(A.layers)&&t.raycast(A,e)===!1&&(o=!1),o===!0&&i===!0){const n=t.children;for(let s=0,r=n.length;s<r;s++)Sz(n[s],A,e,!0)}}class ObA{constructor(A=1,e=0,i=0){return this.radius=A,this.phi=e,this.theta=i,this}set(A,e,i){return this.radius=A,this.phi=e,this.theta=i,this}copy(A){return this.radius=A.radius,this.phi=A.phi,this.theta=A.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(A){return this.setFromCartesianCoords(A.x,A.y,A.z)}setFromCartesianCoords(A,e,i){return this.radius=Math.sqrt(A*A+e*e+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(A,i),this.phi=Math.acos(ah(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:VJ}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=VJ);var ca;(function(t){t.assertEqual=o=>{};function A(o){}t.assertIs=A;function e(o){throw new Error}t.assertNever=e,t.arrayToEnum=o=>{const n={};for(const s of o)n[s]=s;return n},t.getValidEnumValues=o=>{const n=t.objectKeys(o).filter(r=>typeof o[o[r]]!="number"),s={};for(const r of n)s[r]=o[r];return t.objectValues(s)},t.objectValues=o=>t.objectKeys(o).map(function(n){return o[n]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const n=[];for(const s in o)Object.prototype.hasOwnProperty.call(o,s)&&n.push(s);return n},t.find=(o,n)=>{for(const s of o)if(n(s))return s},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function i(o,n=" | "){return o.map(s=>typeof s=="string"?`'${s}'`:s).join(n)}t.joinValues=i,t.jsonStringifyReplacer=(o,n)=>typeof n=="bigint"?n.toString():n})(ca||(ca={}));var WbA;(function(t){t.mergeShapes=(A,e)=>({...A,...e})})(WbA||(WbA={}));const Oi=ca.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Sb=t=>{switch(typeof t){case"undefined":return Oi.undefined;case"string":return Oi.string;case"number":return Number.isNaN(t)?Oi.nan:Oi.number;case"boolean":return Oi.boolean;case"function":return Oi.function;case"bigint":return Oi.bigint;case"symbol":return Oi.symbol;case"object":return Array.isArray(t)?Oi.array:t===null?Oi.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Oi.promise:typeof Map<"u"&&t instanceof Map?Oi.map:typeof Set<"u"&&t instanceof Set?Oi.set:typeof Date<"u"&&t instanceof Date?Oi.date:Oi.object;default:return Oi.unknown}},Wt=ca.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class j0 extends Error{get errors(){return this.issues}constructor(A){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=A}format(A){const e=A||function(n){return n.message},i={_errors:[]},o=n=>{for(const s of n.issues)if(s.code==="invalid_union")s.unionErrors.map(o);else if(s.code==="invalid_return_type")o(s.returnTypeError);else if(s.code==="invalid_arguments")o(s.argumentsError);else if(s.path.length===0)i._errors.push(e(s));else{let r=i,a=0;for(;a<s.path.length;){const g=s.path[a];a===s.path.length-1?(r[g]=r[g]||{_errors:[]},r[g]._errors.push(e(s))):r[g]=r[g]||{_errors:[]},r=r[g],a++}}};return o(this),i}static assert(A){if(!(A instanceof j0))throw new Error(`Not a ZodError: ${A}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ca.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(A=e=>e.message){const e={},i=[];for(const o of this.issues)if(o.path.length>0){const n=o.path[0];e[n]=e[n]||[],e[n].push(A(o))}else i.push(A(o));return{formErrors:i,fieldErrors:e}}get formErrors(){return this.flatten()}}j0.create=t=>new j0(t);const T1=(t,A)=>{let e;switch(t.code){case Wt.invalid_type:t.received===Oi.undefined?e="Required":e=`Expected ${t.expected}, received ${t.received}`;break;case Wt.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(t.expected,ca.jsonStringifyReplacer)}`;break;case Wt.unrecognized_keys:e=`Unrecognized key(s) in object: ${ca.joinValues(t.keys,", ")}`;break;case Wt.invalid_union:e="Invalid input";break;case Wt.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${ca.joinValues(t.options)}`;break;case Wt.invalid_enum_value:e=`Invalid enum value. Expected ${ca.joinValues(t.options)}, received '${t.received}'`;break;case Wt.invalid_arguments:e="Invalid function arguments";break;case Wt.invalid_return_type:e="Invalid function return type";break;case Wt.invalid_date:e="Invalid date";break;case Wt.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(e=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?e=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?e=`Invalid input: must end with "${t.validation.endsWith}"`:ca.assertNever(t.validation):t.validation!=="regex"?e=`Invalid ${t.validation}`:e="Invalid";break;case Wt.too_small:t.type==="array"?e=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?e=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?e=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?e=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?e=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:e="Invalid input";break;case Wt.too_big:t.type==="array"?e=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?e=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?e=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?e=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?e=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:e="Invalid input";break;case Wt.custom:e="Invalid input";break;case Wt.invalid_intersection_types:e="Intersection results could not be merged";break;case Wt.not_multiple_of:e=`Number must be a multiple of ${t.multipleOf}`;break;case Wt.not_finite:e="Number must be finite";break;default:e=A.defaultError,ca.assertNever(t)}return{message:e}};let KSe=T1;function bz(){return KSe}const xz=t=>{const{data:A,path:e,errorMaps:i,issueData:o}=t,n=[...e,...o.path||[]],s={...o,path:n};if(o.message!==void 0)return{...o,path:n,message:o.message};let r="";const a=i.filter(g=>!!g).slice().reverse();for(const g of a)r=g(s,{data:A,defaultError:r}).message;return{...o,path:n,message:r}};function bi(t,A){const e=bz(),i=xz({issueData:A,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,e,e===T1?void 0:T1].filter(o=>!!o)});t.common.issues.push(i)}class fd{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(A,e){const i=[];for(const o of e){if(o.status==="aborted")return Qn;o.status==="dirty"&&A.dirty(),i.push(o.value)}return{status:A.value,value:i}}static async mergeObjectAsync(A,e){const i=[];for(const o of e){const n=await o.key,s=await o.value;i.push({key:n,value:s})}return fd.mergeObjectSync(A,i)}static mergeObjectSync(A,e){const i={};for(const o of e){const{key:n,value:s}=o;if(n.status==="aborted"||s.status==="aborted")return Qn;n.status==="dirty"&&A.dirty(),s.status==="dirty"&&A.dirty(),n.value!=="__proto__"&&(typeof s.value<"u"||o.alwaysSet)&&(i[n.value]=s.value)}return{status:A.value,value:i}}}const Qn=Object.freeze({status:"aborted"}),q1=t=>({status:"dirty",value:t}),vp=t=>({status:"valid",value:t}),ZbA=t=>t.status==="aborted",VbA=t=>t.status==="dirty",oR=t=>t.status==="valid",ZK=t=>typeof Promise<"u"&&t instanceof Promise;var wo;(function(t){t.errToObj=A=>typeof A=="string"?{message:A}:A||{},t.toString=A=>typeof A=="string"?A:A?.message})(wo||(wo={}));class ow{constructor(A,e,i,o){this._cachedPath=[],this.parent=A,this.data=e,this._path=i,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const jbA=(t,A)=>{if(oR(A))return{success:!0,data:A.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new j0(t.common.issues);return this._error=e,this._error}}};function Ds(t){if(!t)return{};const{errorMap:A,invalid_type_error:e,required_error:i,description:o}=t;if(A&&(e||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return A?{errorMap:A,description:o}:{errorMap:(s,r)=>{const{message:a}=t;return s.code==="invalid_enum_value"?{message:a??r.defaultError}:typeof r.data>"u"?{message:a??i??r.defaultError}:s.code!=="invalid_type"?{message:r.defaultError}:{message:a??e??r.defaultError}},description:o}}class Cr{get description(){return this._def.description}_getType(A){return Sb(A.data)}_getOrReturnCtx(A,e){return e||{common:A.parent.common,data:A.data,parsedType:Sb(A.data),schemaErrorMap:this._def.errorMap,path:A.path,parent:A.parent}}_processInputParams(A){return{status:new fd,ctx:{common:A.parent.common,data:A.data,parsedType:Sb(A.data),schemaErrorMap:this._def.errorMap,path:A.path,parent:A.parent}}}_parseSync(A){const e=this._parse(A);if(ZK(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(A){const e=this._parse(A);return Promise.resolve(e)}parse(A,e){const i=this.safeParse(A,e);if(i.success)return i.data;throw i.error}safeParse(A,e){const i={common:{issues:[],async:e?.async??!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:Sb(A)},o=this._parseSync({data:A,path:i.path,parent:i});return jbA(i,o)}"~validate"(A){const e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:Sb(A)};if(!this["~standard"].async)try{const i=this._parseSync({data:A,path:[],parent:e});return oR(i)?{value:i.value}:{issues:e.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:A,path:[],parent:e}).then(i=>oR(i)?{value:i.value}:{issues:e.common.issues})}async parseAsync(A,e){const i=await this.safeParseAsync(A,e);if(i.success)return i.data;throw i.error}async safeParseAsync(A,e){const i={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:Sb(A)},o=this._parse({data:A,path:i.path,parent:i}),n=await(ZK(o)?o:Promise.resolve(o));return jbA(i,n)}refine(A,e){const i=o=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(o):e;return this._refinement((o,n)=>{const s=A(o),r=()=>n.addIssue({code:Wt.custom,...i(o)});return typeof Promise<"u"&&s instanceof Promise?s.then(a=>a?!0:(r(),!1)):s?!0:(r(),!1)})}refinement(A,e){return this._refinement((i,o)=>A(i)?!0:(o.addIssue(typeof e=="function"?e(i,o):e),!1))}_refinement(A){return new zk({schema:this,typeName:Fn.ZodEffects,effect:{type:"refinement",refinement:A}})}superRefine(A){return this._refinement(A)}constructor(A){this.spa=this.safeParseAsync,this._def=A,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return LD.create(this,this._def)}nullable(){return Xk.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return nw.create(this)}promise(){return V1.create(this,this._def)}or(A){return zK.create([this,A],this._def)}and(A){return XK.create(this,A,this._def)}transform(A){return new zk({...Ds(this._def),schema:this,typeName:Fn.ZodEffects,effect:{type:"transform",transform:A}})}default(A){const e=typeof A=="function"?A:()=>A;return new eT({...Ds(this._def),innerType:this,defaultValue:e,typeName:Fn.ZodDefault})}brand(){return new oxA({typeName:Fn.ZodBranded,type:this,...Ds(this._def)})}catch(A){const e=typeof A=="function"?A:()=>A;return new tT({...Ds(this._def),innerType:this,catchValue:e,typeName:Fn.ZodCatch})}describe(A){const e=this.constructor;return new e({...this._def,description:A})}pipe(A){return vz.create(this,A)}readonly(){return iT.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const TSe=/^c[^\s-]{8,}$/i,qSe=/^[0-9a-z]+$/,PSe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,OSe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,WSe=/^[a-z0-9_-]{21}$/i,ZSe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,VSe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,jSe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zSe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let kz;const XSe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$Se=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Abe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ebe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tbe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ibe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zbA="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",obe=new RegExp(`^${zbA}$`);function XbA(t){let A="[0-5]\\d";t.precision?A=`${A}\\.\\d{${t.precision}}`:t.precision==null&&(A=`${A}(\\.\\d+)?`);const e=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${A})${e}`}function nbe(t){return new RegExp(`^${XbA(t)}$`)}function sbe(t){let A=`${zbA}T${XbA(t)}`;const e=[];return e.push(t.local?"Z?":"Z"),t.offset&&e.push("([+-]\\d{2}:?\\d{2})"),A=`${A}(${e.join("|")})`,new RegExp(`^${A}$`)}function rbe(t,A){return!!((A==="v4"||!A)&&XSe.test(t)||(A==="v6"||!A)&&Abe.test(t))}function abe(t,A){if(!ZSe.test(t))return!1;try{const[e]=t.split(".");if(!e)return!1;const i=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),o=JSON.parse(atob(i));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||A&&o.alg!==A)}catch{return!1}}function gbe(t,A){return!!((A==="v4"||!A)&&$Se.test(t)||(A==="v6"||!A)&&ebe.test(t))}class MD extends Cr{_parse(A){if(this._def.coerce&&(A.data=String(A.data)),this._getType(A)!==Oi.string){const n=this._getOrReturnCtx(A);return bi(n,{code:Wt.invalid_type,expected:Oi.string,received:n.parsedType}),Qn}const i=new fd;let o;for(const n of this._def.checks)if(n.kind==="min")A.data.length<n.value&&(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="max")A.data.length>n.value&&(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="length"){const s=A.data.length>n.value,r=A.data.length<n.value;(s||r)&&(o=this._getOrReturnCtx(A,o),s?bi(o,{code:Wt.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):r&&bi(o,{code:Wt.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),i.dirty())}else if(n.kind==="email")jSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"email",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="emoji")kz||(kz=new RegExp(zSe,"u")),kz.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"emoji",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="uuid")OSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"uuid",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="nanoid")WSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"nanoid",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid")TSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"cuid",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid2")qSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"cuid2",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="ulid")PSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"ulid",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="url")try{new URL(A.data)}catch{o=this._getOrReturnCtx(A,o),bi(o,{validation:"url",code:Wt.invalid_string,message:n.message}),i.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"regex",code:Wt.invalid_string,message:n.message}),i.dirty())):n.kind==="trim"?A.data=A.data.trim():n.kind==="includes"?A.data.includes(n.value,n.position)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),i.dirty()):n.kind==="toLowerCase"?A.data=A.data.toLowerCase():n.kind==="toUpperCase"?A.data=A.data.toUpperCase():n.kind==="startsWith"?A.data.startsWith(n.value)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:{startsWith:n.value},message:n.message}),i.dirty()):n.kind==="endsWith"?A.data.endsWith(n.value)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:{endsWith:n.value},message:n.message}),i.dirty()):n.kind==="datetime"?sbe(n).test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:"datetime",message:n.message}),i.dirty()):n.kind==="date"?obe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:"date",message:n.message}),i.dirty()):n.kind==="time"?nbe(n).test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:"time",message:n.message}),i.dirty()):n.kind==="duration"?VSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"duration",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="ip"?rbe(A.data,n.version)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"ip",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="jwt"?abe(A.data,n.alg)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"jwt",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="cidr"?gbe(A.data,n.version)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"cidr",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="base64"?tbe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"base64",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="base64url"?ibe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"base64url",code:Wt.invalid_string,message:n.message}),i.dirty()):ca.assertNever(n);return{status:i.value,value:A.data}}_regex(A,e,i){return this.refinement(o=>A.test(o),{validation:e,code:Wt.invalid_string,...wo.errToObj(i)})}_addCheck(A){return new MD({...this._def,checks:[...this._def.checks,A]})}email(A){return this._addCheck({kind:"email",...wo.errToObj(A)})}url(A){return this._addCheck({kind:"url",...wo.errToObj(A)})}emoji(A){return this._addCheck({kind:"emoji",...wo.errToObj(A)})}uuid(A){return this._addCheck({kind:"uuid",...wo.errToObj(A)})}nanoid(A){return this._addCheck({kind:"nanoid",...wo.errToObj(A)})}cuid(A){return this._addCheck({kind:"cuid",...wo.errToObj(A)})}cuid2(A){return this._addCheck({kind:"cuid2",...wo.errToObj(A)})}ulid(A){return this._addCheck({kind:"ulid",...wo.errToObj(A)})}base64(A){return this._addCheck({kind:"base64",...wo.errToObj(A)})}base64url(A){return this._addCheck({kind:"base64url",...wo.errToObj(A)})}jwt(A){return this._addCheck({kind:"jwt",...wo.errToObj(A)})}ip(A){return this._addCheck({kind:"ip",...wo.errToObj(A)})}cidr(A){return this._addCheck({kind:"cidr",...wo.errToObj(A)})}datetime(A){return typeof A=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:A}):this._addCheck({kind:"datetime",precision:typeof A?.precision>"u"?null:A?.precision,offset:A?.offset??!1,local:A?.local??!1,...wo.errToObj(A?.message)})}date(A){return this._addCheck({kind:"date",message:A})}time(A){return typeof A=="string"?this._addCheck({kind:"time",precision:null,message:A}):this._addCheck({kind:"time",precision:typeof A?.precision>"u"?null:A?.precision,...wo.errToObj(A?.message)})}duration(A){return this._addCheck({kind:"duration",...wo.errToObj(A)})}regex(A,e){return this._addCheck({kind:"regex",regex:A,...wo.errToObj(e)})}includes(A,e){return this._addCheck({kind:"includes",value:A,position:e?.position,...wo.errToObj(e?.message)})}startsWith(A,e){return this._addCheck({kind:"startsWith",value:A,...wo.errToObj(e)})}endsWith(A,e){return this._addCheck({kind:"endsWith",value:A,...wo.errToObj(e)})}min(A,e){return this._addCheck({kind:"min",value:A,...wo.errToObj(e)})}max(A,e){return this._addCheck({kind:"max",value:A,...wo.errToObj(e)})}length(A,e){return this._addCheck({kind:"length",value:A,...wo.errToObj(e)})}nonempty(A){return this.min(1,wo.errToObj(A))}trim(){return new MD({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new MD({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new MD({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(A=>A.kind==="datetime")}get isDate(){return!!this._def.checks.find(A=>A.kind==="date")}get isTime(){return!!this._def.checks.find(A=>A.kind==="time")}get isDuration(){return!!this._def.checks.find(A=>A.kind==="duration")}get isEmail(){return!!this._def.checks.find(A=>A.kind==="email")}get isURL(){return!!this._def.checks.find(A=>A.kind==="url")}get isEmoji(){return!!this._def.checks.find(A=>A.kind==="emoji")}get isUUID(){return!!this._def.checks.find(A=>A.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(A=>A.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(A=>A.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(A=>A.kind==="cuid2")}get isULID(){return!!this._def.checks.find(A=>A.kind==="ulid")}get isIP(){return!!this._def.checks.find(A=>A.kind==="ip")}get isCIDR(){return!!this._def.checks.find(A=>A.kind==="cidr")}get isBase64(){return!!this._def.checks.find(A=>A.kind==="base64")}get isBase64url(){return!!this._def.checks.find(A=>A.kind==="base64url")}get minLength(){let A=null;for(const e of this._def.checks)e.kind==="min"&&(A===null||e.value>A)&&(A=e.value);return A}get maxLength(){let A=null;for(const e of this._def.checks)e.kind==="max"&&(A===null||e.value<A)&&(A=e.value);return A}}MD.create=t=>new MD({checks:[],typeName:Fn.ZodString,coerce:t?.coerce??!1,...Ds(t)});function Ibe(t,A){const e=(t.toString().split(".")[1]||"").length,i=(A.toString().split(".")[1]||"").length,o=e>i?e:i,n=Number.parseInt(t.toFixed(o).replace(".","")),s=Number.parseInt(A.toFixed(o).replace(".",""));return n%s/10**o}class nR extends Cr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(A){if(this._def.coerce&&(A.data=Number(A.data)),this._getType(A)!==Oi.number){const n=this._getOrReturnCtx(A);return bi(n,{code:Wt.invalid_type,expected:Oi.number,received:n.parsedType}),Qn}let i;const o=new fd;for(const n of this._def.checks)n.kind==="int"?ca.isInteger(A.data)||(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.invalid_type,expected:"integer",received:"float",message:n.message}),o.dirty()):n.kind==="min"?(n.inclusive?A.data<n.value:A.data<=n.value)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),o.dirty()):n.kind==="max"?(n.inclusive?A.data>n.value:A.data>=n.value)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),o.dirty()):n.kind==="multipleOf"?Ibe(A.data,n.value)!==0&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.not_multiple_of,multipleOf:n.value,message:n.message}),o.dirty()):n.kind==="finite"?Number.isFinite(A.data)||(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.not_finite,message:n.message}),o.dirty()):ca.assertNever(n);return{status:o.value,value:A.data}}gte(A,e){return this.setLimit("min",A,!0,wo.toString(e))}gt(A,e){return this.setLimit("min",A,!1,wo.toString(e))}lte(A,e){return this.setLimit("max",A,!0,wo.toString(e))}lt(A,e){return this.setLimit("max",A,!1,wo.toString(e))}setLimit(A,e,i,o){return new nR({...this._def,checks:[...this._def.checks,{kind:A,value:e,inclusive:i,message:wo.toString(o)}]})}_addCheck(A){return new nR({...this._def,checks:[...this._def.checks,A]})}int(A){return this._addCheck({kind:"int",message:wo.toString(A)})}positive(A){return this._addCheck({kind:"min",value:0,inclusive:!1,message:wo.toString(A)})}negative(A){return this._addCheck({kind:"max",value:0,inclusive:!1,message:wo.toString(A)})}nonpositive(A){return this._addCheck({kind:"max",value:0,inclusive:!0,message:wo.toString(A)})}nonnegative(A){return this._addCheck({kind:"min",value:0,inclusive:!0,message:wo.toString(A)})}multipleOf(A,e){return this._addCheck({kind:"multipleOf",value:A,message:wo.toString(e)})}finite(A){return this._addCheck({kind:"finite",message:wo.toString(A)})}safe(A){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:wo.toString(A)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:wo.toString(A)})}get minValue(){let A=null;for(const e of this._def.checks)e.kind==="min"&&(A===null||e.value>A)&&(A=e.value);return A}get maxValue(){let A=null;for(const e of this._def.checks)e.kind==="max"&&(A===null||e.value<A)&&(A=e.value);return A}get isInt(){return!!this._def.checks.find(A=>A.kind==="int"||A.kind==="multipleOf"&&ca.isInteger(A.value))}get isFinite(){let A=null,e=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(e===null||i.value>e)&&(e=i.value):i.kind==="max"&&(A===null||i.value<A)&&(A=i.value)}return Number.isFinite(e)&&Number.isFinite(A)}}nR.create=t=>new nR({checks:[],typeName:Fn.ZodNumber,coerce:t?.coerce||!1,...Ds(t)});class P1 extends Cr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(A){if(this._def.coerce)try{A.data=BigInt(A.data)}catch{return this._getInvalidInput(A)}if(this._getType(A)!==Oi.bigint)return this._getInvalidInput(A);let i;const o=new fd;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?A.data<n.value:A.data<=n.value)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),o.dirty()):n.kind==="max"?(n.inclusive?A.data>n.value:A.data>=n.value)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),o.dirty()):n.kind==="multipleOf"?A.data%n.value!==BigInt(0)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.not_multiple_of,multipleOf:n.value,message:n.message}),o.dirty()):ca.assertNever(n);return{status:o.value,value:A.data}}_getInvalidInput(A){const e=this._getOrReturnCtx(A);return bi(e,{code:Wt.invalid_type,expected:Oi.bigint,received:e.parsedType}),Qn}gte(A,e){return this.setLimit("min",A,!0,wo.toString(e))}gt(A,e){return this.setLimit("min",A,!1,wo.toString(e))}lte(A,e){return this.setLimit("max",A,!0,wo.toString(e))}lt(A,e){return this.setLimit("max",A,!1,wo.toString(e))}setLimit(A,e,i,o){return new P1({...this._def,checks:[...this._def.checks,{kind:A,value:e,inclusive:i,message:wo.toString(o)}]})}_addCheck(A){return new P1({...this._def,checks:[...this._def.checks,A]})}positive(A){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:wo.toString(A)})}negative(A){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:wo.toString(A)})}nonpositive(A){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:wo.toString(A)})}nonnegative(A){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:wo.toString(A)})}multipleOf(A,e){return this._addCheck({kind:"multipleOf",value:A,message:wo.toString(e)})}get minValue(){let A=null;for(const e of this._def.checks)e.kind==="min"&&(A===null||e.value>A)&&(A=e.value);return A}get maxValue(){let A=null;for(const e of this._def.checks)e.kind==="max"&&(A===null||e.value<A)&&(A=e.value);return A}}P1.create=t=>new P1({checks:[],typeName:Fn.ZodBigInt,coerce:t?.coerce??!1,...Ds(t)});class Gz extends Cr{_parse(A){if(this._def.coerce&&(A.data=!!A.data),this._getType(A)!==Oi.boolean){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.boolean,received:i.parsedType}),Qn}return vp(A.data)}}Gz.create=t=>new Gz({typeName:Fn.ZodBoolean,coerce:t?.coerce||!1,...Ds(t)});class VK extends Cr{_parse(A){if(this._def.coerce&&(A.data=new Date(A.data)),this._getType(A)!==Oi.date){const n=this._getOrReturnCtx(A);return bi(n,{code:Wt.invalid_type,expected:Oi.date,received:n.parsedType}),Qn}if(Number.isNaN(A.data.getTime())){const n=this._getOrReturnCtx(A);return bi(n,{code:Wt.invalid_date}),Qn}const i=new fd;let o;for(const n of this._def.checks)n.kind==="min"?A.data.getTime()<n.value&&(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),i.dirty()):n.kind==="max"?A.data.getTime()>n.value&&(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),i.dirty()):ca.assertNever(n);return{status:i.value,value:new Date(A.data.getTime())}}_addCheck(A){return new VK({...this._def,checks:[...this._def.checks,A]})}min(A,e){return this._addCheck({kind:"min",value:A.getTime(),message:wo.toString(e)})}max(A,e){return this._addCheck({kind:"max",value:A.getTime(),message:wo.toString(e)})}get minDate(){let A=null;for(const e of this._def.checks)e.kind==="min"&&(A===null||e.value>A)&&(A=e.value);return A!=null?new Date(A):null}get maxDate(){let A=null;for(const e of this._def.checks)e.kind==="max"&&(A===null||e.value<A)&&(A=e.value);return A!=null?new Date(A):null}}VK.create=t=>new VK({checks:[],coerce:t?.coerce||!1,typeName:Fn.ZodDate,...Ds(t)});class $bA extends Cr{_parse(A){if(this._getType(A)!==Oi.symbol){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.symbol,received:i.parsedType}),Qn}return vp(A.data)}}$bA.create=t=>new $bA({typeName:Fn.ZodSymbol,...Ds(t)});class Fz extends Cr{_parse(A){if(this._getType(A)!==Oi.undefined){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.undefined,received:i.parsedType}),Qn}return vp(A.data)}}Fz.create=t=>new Fz({typeName:Fn.ZodUndefined,...Ds(t)});class jK extends Cr{_parse(A){if(this._getType(A)!==Oi.null){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.null,received:i.parsedType}),Qn}return vp(A.data)}}jK.create=t=>new jK({typeName:Fn.ZodNull,...Ds(t)});class O1 extends Cr{constructor(){super(...arguments),this._any=!0}_parse(A){return vp(A.data)}}O1.create=t=>new O1({typeName:Fn.ZodAny,...Ds(t)});class sR extends Cr{constructor(){super(...arguments),this._unknown=!0}_parse(A){return vp(A.data)}}sR.create=t=>new sR({typeName:Fn.ZodUnknown,...Ds(t)});class bb extends Cr{_parse(A){const e=this._getOrReturnCtx(A);return bi(e,{code:Wt.invalid_type,expected:Oi.never,received:e.parsedType}),Qn}}bb.create=t=>new bb({typeName:Fn.ZodNever,...Ds(t)});class AxA extends Cr{_parse(A){if(this._getType(A)!==Oi.undefined){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.void,received:i.parsedType}),Qn}return vp(A.data)}}AxA.create=t=>new AxA({typeName:Fn.ZodVoid,...Ds(t)});class nw extends Cr{_parse(A){const{ctx:e,status:i}=this._processInputParams(A),o=this._def;if(e.parsedType!==Oi.array)return bi(e,{code:Wt.invalid_type,expected:Oi.array,received:e.parsedType}),Qn;if(o.exactLength!==null){const s=e.data.length>o.exactLength.value,r=e.data.length<o.exactLength.value;(s||r)&&(bi(e,{code:s?Wt.too_big:Wt.too_small,minimum:r?o.exactLength.value:void 0,maximum:s?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),i.dirty())}if(o.minLength!==null&&e.data.length<o.minLength.value&&(bi(e,{code:Wt.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),i.dirty()),o.maxLength!==null&&e.data.length>o.maxLength.value&&(bi(e,{code:Wt.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),i.dirty()),e.common.async)return Promise.all([...e.data].map((s,r)=>o.type._parseAsync(new ow(e,s,e.path,r)))).then(s=>fd.mergeArray(i,s));const n=[...e.data].map((s,r)=>o.type._parseSync(new ow(e,s,e.path,r)));return fd.mergeArray(i,n)}get element(){return this._def.type}min(A,e){return new nw({...this._def,minLength:{value:A,message:wo.toString(e)}})}max(A,e){return new nw({...this._def,maxLength:{value:A,message:wo.toString(e)}})}length(A,e){return new nw({...this._def,exactLength:{value:A,message:wo.toString(e)}})}nonempty(A){return this.min(1,A)}}nw.create=(t,A)=>new nw({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Fn.ZodArray,...Ds(A)});function rR(t){if(t instanceof Sl){const A={};for(const e in t.shape){const i=t.shape[e];A[e]=LD.create(rR(i))}return new Sl({...t._def,shape:()=>A})}else return t instanceof nw?new nw({...t._def,type:rR(t.element)}):t instanceof LD?LD.create(rR(t.unwrap())):t instanceof Xk?Xk.create(rR(t.unwrap())):t instanceof UD?UD.create(t.items.map(A=>rR(A))):t}class Sl extends Cr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const A=this._def.shape(),e=ca.objectKeys(A);return this._cached={shape:A,keys:e},this._cached}_parse(A){if(this._getType(A)!==Oi.object){const g=this._getOrReturnCtx(A);return bi(g,{code:Wt.invalid_type,expected:Oi.object,received:g.parsedType}),Qn}const{status:i,ctx:o}=this._processInputParams(A),{shape:n,keys:s}=this._getCached(),r=[];if(!(this._def.catchall instanceof bb&&this._def.unknownKeys==="strip"))for(const g in o.data)s.includes(g)||r.push(g);const a=[];for(const g of s){const I=n[g],c=o.data[g];a.push({key:{status:"valid",value:g},value:I._parse(new ow(o,c,o.path,g)),alwaysSet:g in o.data})}if(this._def.catchall instanceof bb){const g=this._def.unknownKeys;if(g==="passthrough")for(const I of r)a.push({key:{status:"valid",value:I},value:{status:"valid",value:o.data[I]}});else if(g==="strict")r.length>0&&(bi(o,{code:Wt.unrecognized_keys,keys:r}),i.dirty());else if(g!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const g=this._def.catchall;for(const I of r){const c=o.data[I];a.push({key:{status:"valid",value:I},value:g._parse(new ow(o,c,o.path,I)),alwaysSet:I in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const g=[];for(const I of a){const c=await I.key,B=await I.value;g.push({key:c,value:B,alwaysSet:I.alwaysSet})}return g}).then(g=>fd.mergeObjectSync(i,g)):fd.mergeObjectSync(i,a)}get shape(){return this._def.shape()}strict(A){return wo.errToObj,new Sl({...this._def,unknownKeys:"strict",...A!==void 0?{errorMap:(e,i)=>{const o=this._def.errorMap?.(e,i).message??i.defaultError;return e.code==="unrecognized_keys"?{message:wo.errToObj(A).message??o}:{message:o}}}:{}})}strip(){return new Sl({...this._def,unknownKeys:"strip"})}passthrough(){return new Sl({...this._def,unknownKeys:"passthrough"})}extend(A){return new Sl({...this._def,shape:()=>({...this._def.shape(),...A})})}merge(A){return new Sl({unknownKeys:A._def.unknownKeys,catchall:A._def.catchall,shape:()=>({...this._def.shape(),...A._def.shape()}),typeName:Fn.ZodObject})}setKey(A,e){return this.augment({[A]:e})}catchall(A){return new Sl({...this._def,catchall:A})}pick(A){const e={};for(const i of ca.objectKeys(A))A[i]&&this.shape[i]&&(e[i]=this.shape[i]);return new Sl({...this._def,shape:()=>e})}omit(A){const e={};for(const i of ca.objectKeys(this.shape))A[i]||(e[i]=this.shape[i]);return new Sl({...this._def,shape:()=>e})}deepPartial(){return rR(this)}partial(A){const e={};for(const i of ca.objectKeys(this.shape)){const o=this.shape[i];A&&!A[i]?e[i]=o:e[i]=o.optional()}return new Sl({...this._def,shape:()=>e})}required(A){const e={};for(const i of ca.objectKeys(this.shape))if(A&&!A[i])e[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof LD;)n=n._def.innerType;e[i]=n}return new Sl({...this._def,shape:()=>e})}keyof(){return txA(ca.objectKeys(this.shape))}}Sl.create=(t,A)=>new Sl({shape:()=>t,unknownKeys:"strip",catchall:bb.create(),typeName:Fn.ZodObject,...Ds(A)}),Sl.strictCreate=(t,A)=>new Sl({shape:()=>t,unknownKeys:"strict",catchall:bb.create(),typeName:Fn.ZodObject,...Ds(A)}),Sl.lazycreate=(t,A)=>new Sl({shape:t,unknownKeys:"strip",catchall:bb.create(),typeName:Fn.ZodObject,...Ds(A)});class zK extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A),i=this._def.options;function o(n){for(const r of n)if(r.result.status==="valid")return r.result;for(const r of n)if(r.result.status==="dirty")return e.common.issues.push(...r.ctx.common.issues),r.result;const s=n.map(r=>new j0(r.ctx.common.issues));return bi(e,{code:Wt.invalid_union,unionErrors:s}),Qn}if(e.common.async)return Promise.all(i.map(async n=>{const s={...e,common:{...e.common,issues:[]},parent:null};return{result:await n._parseAsync({data:e.data,path:e.path,parent:s}),ctx:s}})).then(o);{let n;const s=[];for(const a of i){const g={...e,common:{...e.common,issues:[]},parent:null},I=a._parseSync({data:e.data,path:e.path,parent:g});if(I.status==="valid")return I;I.status==="dirty"&&!n&&(n={result:I,ctx:g}),g.common.issues.length&&s.push(g.common.issues)}if(n)return e.common.issues.push(...n.ctx.common.issues),n.result;const r=s.map(a=>new j0(a));return bi(e,{code:Wt.invalid_union,unionErrors:r}),Qn}}get options(){return this._def.options}}zK.create=(t,A)=>new zK({options:t,typeName:Fn.ZodUnion,...Ds(A)});const vD=t=>t instanceof Nz?vD(t.schema):t instanceof zk?vD(t.innerType()):t instanceof AT?[t.value]:t instanceof jk?t.options:t instanceof Mz?ca.objectValues(t.enum):t instanceof eT?vD(t._def.innerType):t instanceof Fz?[void 0]:t instanceof jK?[null]:t instanceof LD?[void 0,...vD(t.unwrap())]:t instanceof Xk?[null,...vD(t.unwrap())]:t instanceof oxA||t instanceof iT?vD(t.unwrap()):t instanceof tT?vD(t._def.innerType):[];class _z extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A);if(e.parsedType!==Oi.object)return bi(e,{code:Wt.invalid_type,expected:Oi.object,received:e.parsedType}),Qn;const i=this.discriminator,o=e.data[i],n=this.optionsMap.get(o);return n?e.common.async?n._parseAsync({data:e.data,path:e.path,parent:e}):n._parseSync({data:e.data,path:e.path,parent:e}):(bi(e,{code:Wt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),Qn)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(A,e,i){const o=new Map;for(const n of e){const s=vD(n.shape[A]);if(!s.length)throw new Error(`A discriminator value for key \`${A}\` could not be extracted from all schema options`);for(const r of s){if(o.has(r))throw new Error(`Discriminator property ${String(A)} has duplicate value ${String(r)}`);o.set(r,n)}}return new _z({typeName:Fn.ZodDiscriminatedUnion,discriminator:A,options:e,optionsMap:o,...Ds(i)})}}function Rz(t,A){const e=Sb(t),i=Sb(A);if(t===A)return{valid:!0,data:t};if(e===Oi.object&&i===Oi.object){const o=ca.objectKeys(A),n=ca.objectKeys(t).filter(r=>o.indexOf(r)!==-1),s={...t,...A};for(const r of n){const a=Rz(t[r],A[r]);if(!a.valid)return{valid:!1};s[r]=a.data}return{valid:!0,data:s}}else if(e===Oi.array&&i===Oi.array){if(t.length!==A.length)return{valid:!1};const o=[];for(let n=0;n<t.length;n++){const s=t[n],r=A[n],a=Rz(s,r);if(!a.valid)return{valid:!1};o.push(a.data)}return{valid:!0,data:o}}else return e===Oi.date&&i===Oi.date&&+t==+A?{valid:!0,data:t}:{valid:!1}}class XK extends Cr{_parse(A){const{status:e,ctx:i}=this._processInputParams(A),o=(n,s)=>{if(ZbA(n)||ZbA(s))return Qn;const r=Rz(n.value,s.value);return r.valid?((VbA(n)||VbA(s))&&e.dirty(),{status:e.value,value:r.data}):(bi(i,{code:Wt.invalid_intersection_types}),Qn)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([n,s])=>o(n,s)):o(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}XK.create=(t,A,e)=>new XK({left:t,right:A,typeName:Fn.ZodIntersection,...Ds(e)});class UD extends Cr{_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.parsedType!==Oi.array)return bi(i,{code:Wt.invalid_type,expected:Oi.array,received:i.parsedType}),Qn;if(i.data.length<this._def.items.length)return bi(i,{code:Wt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Qn;!this._def.rest&&i.data.length>this._def.items.length&&(bi(i,{code:Wt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const n=[...i.data].map((s,r)=>{const a=this._def.items[r]||this._def.rest;return a?a._parse(new ow(i,s,i.path,r)):null}).filter(s=>!!s);return i.common.async?Promise.all(n).then(s=>fd.mergeArray(e,s)):fd.mergeArray(e,n)}get items(){return this._def.items}rest(A){return new UD({...this._def,rest:A})}}UD.create=(t,A)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new UD({items:t,typeName:Fn.ZodTuple,rest:null,...Ds(A)})};class $K extends Cr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.parsedType!==Oi.object)return bi(i,{code:Wt.invalid_type,expected:Oi.object,received:i.parsedType}),Qn;const o=[],n=this._def.keyType,s=this._def.valueType;for(const r in i.data)o.push({key:n._parse(new ow(i,r,i.path,r)),value:s._parse(new ow(i,i.data[r],i.path,r)),alwaysSet:r in i.data});return i.common.async?fd.mergeObjectAsync(e,o):fd.mergeObjectSync(e,o)}get element(){return this._def.valueType}static create(A,e,i){return e instanceof Cr?new $K({keyType:A,valueType:e,typeName:Fn.ZodRecord,...Ds(i)}):new $K({keyType:MD.create(),valueType:A,typeName:Fn.ZodRecord,...Ds(e)})}}class exA extends Cr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.parsedType!==Oi.map)return bi(i,{code:Wt.invalid_type,expected:Oi.map,received:i.parsedType}),Qn;const o=this._def.keyType,n=this._def.valueType,s=[...i.data.entries()].map(([r,a],g)=>({key:o._parse(new ow(i,r,i.path,[g,"key"])),value:n._parse(new ow(i,a,i.path,[g,"value"]))}));if(i.common.async){const r=new Map;return Promise.resolve().then(async()=>{for(const a of s){const g=await a.key,I=await a.value;if(g.status==="aborted"||I.status==="aborted")return Qn;(g.status==="dirty"||I.status==="dirty")&&e.dirty(),r.set(g.value,I.value)}return{status:e.value,value:r}})}else{const r=new Map;for(const a of s){const g=a.key,I=a.value;if(g.status==="aborted"||I.status==="aborted")return Qn;(g.status==="dirty"||I.status==="dirty")&&e.dirty(),r.set(g.value,I.value)}return{status:e.value,value:r}}}}exA.create=(t,A,e)=>new exA({valueType:A,keyType:t,typeName:Fn.ZodMap,...Ds(e)});class W1 extends Cr{_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.parsedType!==Oi.set)return bi(i,{code:Wt.invalid_type,expected:Oi.set,received:i.parsedType}),Qn;const o=this._def;o.minSize!==null&&i.data.size<o.minSize.value&&(bi(i,{code:Wt.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),e.dirty()),o.maxSize!==null&&i.data.size>o.maxSize.value&&(bi(i,{code:Wt.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),e.dirty());const n=this._def.valueType;function s(a){const g=new Set;for(const I of a){if(I.status==="aborted")return Qn;I.status==="dirty"&&e.dirty(),g.add(I.value)}return{status:e.value,value:g}}const r=[...i.data.values()].map((a,g)=>n._parse(new ow(i,a,i.path,g)));return i.common.async?Promise.all(r).then(a=>s(a)):s(r)}min(A,e){return new W1({...this._def,minSize:{value:A,message:wo.toString(e)}})}max(A,e){return new W1({...this._def,maxSize:{value:A,message:wo.toString(e)}})}size(A,e){return this.min(A,e).max(A,e)}nonempty(A){return this.min(1,A)}}W1.create=(t,A)=>new W1({valueType:t,minSize:null,maxSize:null,typeName:Fn.ZodSet,...Ds(A)});class Z1 extends Cr{constructor(){super(...arguments),this.validate=this.implement}_parse(A){const{ctx:e}=this._processInputParams(A);if(e.parsedType!==Oi.function)return bi(e,{code:Wt.invalid_type,expected:Oi.function,received:e.parsedType}),Qn;function i(r,a){return xz({data:r,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,bz(),T1].filter(g=>!!g),issueData:{code:Wt.invalid_arguments,argumentsError:a}})}function o(r,a){return xz({data:r,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,bz(),T1].filter(g=>!!g),issueData:{code:Wt.invalid_return_type,returnTypeError:a}})}const n={errorMap:e.common.contextualErrorMap},s=e.data;if(this._def.returns instanceof V1){const r=this;return vp(async function(...a){const g=new j0([]),I=await r._def.args.parseAsync(a,n).catch(C=>{throw g.addIssue(i(a,C)),g}),c=await Reflect.apply(s,this,I);return await r._def.returns._def.type.parseAsync(c,n).catch(C=>{throw g.addIssue(o(c,C)),g})})}else{const r=this;return vp(function(...a){const g=r._def.args.safeParse(a,n);if(!g.success)throw new j0([i(a,g.error)]);const I=Reflect.apply(s,this,g.data),c=r._def.returns.safeParse(I,n);if(!c.success)throw new j0([o(I,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...A){return new Z1({...this._def,args:UD.create(A).rest(sR.create())})}returns(A){return new Z1({...this._def,returns:A})}implement(A){return this.parse(A)}strictImplement(A){return this.parse(A)}static create(A,e,i){return new Z1({args:A||UD.create([]).rest(sR.create()),returns:e||sR.create(),typeName:Fn.ZodFunction,...Ds(i)})}}class Nz extends Cr{get schema(){return this._def.getter()}_parse(A){const{ctx:e}=this._processInputParams(A);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Nz.create=(t,A)=>new Nz({getter:t,typeName:Fn.ZodLazy,...Ds(A)});class AT extends Cr{_parse(A){if(A.data!==this._def.value){const e=this._getOrReturnCtx(A);return bi(e,{received:e.data,code:Wt.invalid_literal,expected:this._def.value}),Qn}return{status:"valid",value:A.data}}get value(){return this._def.value}}AT.create=(t,A)=>new AT({value:t,typeName:Fn.ZodLiteral,...Ds(A)});function txA(t,A){return new jk({values:t,typeName:Fn.ZodEnum,...Ds(A)})}class jk extends Cr{_parse(A){if(typeof A.data!="string"){const e=this._getOrReturnCtx(A),i=this._def.values;return bi(e,{expected:ca.joinValues(i),received:e.parsedType,code:Wt.invalid_type}),Qn}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(A.data)){const e=this._getOrReturnCtx(A),i=this._def.values;return bi(e,{received:e.data,code:Wt.invalid_enum_value,options:i}),Qn}return vp(A.data)}get options(){return this._def.values}get enum(){const A={};for(const e of this._def.values)A[e]=e;return A}get Values(){const A={};for(const e of this._def.values)A[e]=e;return A}get Enum(){const A={};for(const e of this._def.values)A[e]=e;return A}extract(A,e=this._def){return jk.create(A,{...this._def,...e})}exclude(A,e=this._def){return jk.create(this.options.filter(i=>!A.includes(i)),{...this._def,...e})}}jk.create=txA;class Mz extends Cr{_parse(A){const e=ca.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(A);if(i.parsedType!==Oi.string&&i.parsedType!==Oi.number){const o=ca.objectValues(e);return bi(i,{expected:ca.joinValues(o),received:i.parsedType,code:Wt.invalid_type}),Qn}if(this._cache||(this._cache=new Set(ca.getValidEnumValues(this._def.values))),!this._cache.has(A.data)){const o=ca.objectValues(e);return bi(i,{received:i.data,code:Wt.invalid_enum_value,options:o}),Qn}return vp(A.data)}get enum(){return this._def.values}}Mz.create=(t,A)=>new Mz({values:t,typeName:Fn.ZodNativeEnum,...Ds(A)});class V1 extends Cr{unwrap(){return this._def.type}_parse(A){const{ctx:e}=this._processInputParams(A);if(e.parsedType!==Oi.promise&&e.common.async===!1)return bi(e,{code:Wt.invalid_type,expected:Oi.promise,received:e.parsedType}),Qn;const i=e.parsedType===Oi.promise?e.data:Promise.resolve(e.data);return vp(i.then(o=>this._def.type.parseAsync(o,{path:e.path,errorMap:e.common.contextualErrorMap})))}}V1.create=(t,A)=>new V1({type:t,typeName:Fn.ZodPromise,...Ds(A)});class zk extends Cr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Fn.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(A){const{status:e,ctx:i}=this._processInputParams(A),o=this._def.effect||null,n={addIssue:s=>{bi(i,s),s.fatal?e.abort():e.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),o.type==="preprocess"){const s=o.transform(i.data,n);if(i.common.async)return Promise.resolve(s).then(async r=>{if(e.value==="aborted")return Qn;const a=await this._def.schema._parseAsync({data:r,path:i.path,parent:i});return a.status==="aborted"?Qn:a.status==="dirty"||e.value==="dirty"?q1(a.value):a});{if(e.value==="aborted")return Qn;const r=this._def.schema._parseSync({data:s,path:i.path,parent:i});return r.status==="aborted"?Qn:r.status==="dirty"||e.value==="dirty"?q1(r.value):r}}if(o.type==="refinement"){const s=r=>{const a=o.refinement(r,n);if(i.common.async)return Promise.resolve(a);if(a instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return r};if(i.common.async===!1){const r=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return r.status==="aborted"?Qn:(r.status==="dirty"&&e.dirty(),s(r.value),{status:e.value,value:r.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(r=>r.status==="aborted"?Qn:(r.status==="dirty"&&e.dirty(),s(r.value).then(()=>({status:e.value,value:r.value}))))}if(o.type==="transform")if(i.common.async===!1){const s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!oR(s))return Qn;const r=o.transform(s.value,n);if(r instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:r}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>oR(s)?Promise.resolve(o.transform(s.value,n)).then(r=>({status:e.value,value:r})):Qn);ca.assertNever(o)}}zk.create=(t,A,e)=>new zk({schema:t,typeName:Fn.ZodEffects,effect:A,...Ds(e)}),zk.createWithPreprocess=(t,A,e)=>new zk({schema:A,effect:{type:"preprocess",transform:t},typeName:Fn.ZodEffects,...Ds(e)});class LD extends Cr{_parse(A){return this._getType(A)===Oi.undefined?vp(void 0):this._def.innerType._parse(A)}unwrap(){return this._def.innerType}}LD.create=(t,A)=>new LD({innerType:t,typeName:Fn.ZodOptional,...Ds(A)});class Xk extends Cr{_parse(A){return this._getType(A)===Oi.null?vp(null):this._def.innerType._parse(A)}unwrap(){return this._def.innerType}}Xk.create=(t,A)=>new Xk({innerType:t,typeName:Fn.ZodNullable,...Ds(A)});class eT extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A);let i=e.data;return e.parsedType===Oi.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}eT.create=(t,A)=>new eT({innerType:t,typeName:Fn.ZodDefault,defaultValue:typeof A.default=="function"?A.default:()=>A.default,...Ds(A)});class tT extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A),i={...e,common:{...e.common,issues:[]}},o=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return ZK(o)?o.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new j0(i.common.issues)},input:i.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new j0(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}tT.create=(t,A)=>new tT({innerType:t,typeName:Fn.ZodCatch,catchValue:typeof A.catch=="function"?A.catch:()=>A.catch,...Ds(A)});class ixA extends Cr{_parse(A){if(this._getType(A)!==Oi.nan){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.nan,received:i.parsedType}),Qn}return{status:"valid",value:A.data}}}ixA.create=t=>new ixA({typeName:Fn.ZodNaN,...Ds(t)});class oxA extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A),i=e.data;return this._def.type._parse({data:i,path:e.path,parent:e})}unwrap(){return this._def.type}}class vz extends Cr{_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?Qn:n.status==="dirty"?(e.dirty(),q1(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const o=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?Qn:o.status==="dirty"?(e.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:i.path,parent:i})}}static create(A,e){return new vz({in:A,out:e,typeName:Fn.ZodPipeline})}}class iT extends Cr{_parse(A){const e=this._def.innerType._parse(A),i=o=>(oR(o)&&(o.value=Object.freeze(o.value)),o);return ZK(e)?e.then(o=>i(o)):i(e)}unwrap(){return this._def.innerType}}iT.create=(t,A)=>new iT({innerType:t,typeName:Fn.ZodReadonly,...Ds(A)});function nxA(t,A){const e=typeof t=="function"?t(A):typeof t=="string"?{message:t}:t;return typeof e=="string"?{message:e}:e}function gh(t,A={},e){return t?O1.create().superRefine((i,o)=>{const n=t(i);if(n instanceof Promise)return n.then(s=>{if(!s){const r=nxA(A,i),a=r.fatal??e??!0;o.addIssue({code:"custom",...r,fatal:a})}});if(!n){const s=nxA(A,i),r=s.fatal??e??!0;o.addIssue({code:"custom",...s,fatal:r})}}):O1.create()}var Fn;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Fn||(Fn={}));const v=MD.create,NA=nR.create,te=Gz.create,sxA=jK.create,Yg=O1.create,cbe=sR.create;bb.create;const fe=nw.create,xA=Sl.create,Zt=zK.create,rE=_z.create;XK.create,UD.create;const $r=$K.create,xb=Z1.create,lA=AT.create,Ze=jk.create,kb=V1.create;LD.create,Xk.create;var rxA={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},Uz=new Set;for(const[t,A]of Object.entries(rxA)){Uz.add(t);for(const e of Object.keys(A.variants))Uz.add(e)}function Bbe(t){for(const[A,e]of Object.entries(rxA))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var axA={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function nm(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=nm(t.x),g=nm(t.x),I=nm(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),o=t.slice(0,-i.length);if(i in axA&&!Uz.has(i)){const r=axA[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(o)*r}}const{baseUnit:n,conversionFactor:s}=Bbe(i);return{parsedUnit:i,unitOfValue:n,value:s*Number.parseFloat(o)}}var aR=v().or(NA()).transform(t=>nm(t).value),gR=v().or(NA()).transform(t=>nm(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),Lz=v().or(NA()).transform(t=>nm(t).value),z0=v().or(NA()).transform(t=>nm(t).value),VA=v().or(NA()).transform(t=>nm(t).value),HD=v().or(NA()).transform(t=>nm(t).value),Ie=VA,Cbe=v().or(NA()).transform(t=>nm(t).value),j1=v().or(NA()).transform(t=>nm(t).value),lbe=j1,Tf=j1,gxA=v().datetime(),BI=v().or(NA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),IxA=NA().or(v().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),co=xA({x:Ie,y:Ie}),Qbe=co,IR=xA({x:Ie,y:Ie,z:Ie}),Ebe=IR,Hz=xA({width:NA(),height:NA()}),hbe=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Ai=t=>v().optional().default(()=>`${t}_${hbe(10)}`),$k=Ze(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),oT=Ze(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),dB=xA({type:lA("source_component"),ftype:v().optional(),source_component_id:v(),name:v(),manufacturer_part_number:v().optional(),supplier_part_numbers:$r(oT,fe(v())).optional(),display_value:v().optional(),are_pins_interchangeable:te().optional(),internally_connected_source_port_ids:fe(fe(v())).optional(),source_group_id:v().optional(),subcircuit_id:v().optional()}),Yz=dB.extend({ftype:lA("simple_capacitor"),capacitance:gR,max_voltage_rating:z0.optional(),display_capacitance:v().optional(),max_decoupling_trace_length:Ie.optional()}),Jz=dB.extend({ftype:lA("simple_resistor"),resistance:aR,display_resistance:v().optional()}),nT=dB.extend({ftype:lA("simple_diode")}),cxA=dB.extend({ftype:lA("simple_fiducial")}),Kz=nT.extend({ftype:lA("simple_led"),color:v().optional(),wavelength:v().optional()}),BxA=dB.extend({ftype:lA("simple_ground")}),Tz=dB.extend({ftype:lA("simple_chip")}),qz=dB.extend({ftype:lA("simple_power_source"),voltage:z0}),ube=dB.extend({ftype:lA("simple_fuse"),current_rating_amps:NA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:NA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),Pz=dB.extend({ftype:lA("simple_battery"),capacity:IxA}),Oz=dB.extend({ftype:lA("simple_inductor"),inductance:Lz,max_current_rating:NA().optional()}),Wz=dB.extend({ftype:lA("simple_push_button")}),Zz=dB.extend({ftype:lA("simple_potentiometer"),max_resistance:aR}),CxA=dB.extend({ftype:lA("simple_crystal"),frequency:NA().describe("Frequency in Hz"),load_capacitance:NA().optional().describe("Load capacitance in pF")}),Vz=dB.extend({ftype:lA("simple_pin_header"),pin_count:NA(),gender:Ze(["male","female"]).optional().default("male")}),jz=dB.extend({ftype:lA("simple_pinout")}),zz=dB.extend({ftype:lA("simple_resonator"),load_capacitance:gR,equivalent_series_resistance:aR.optional(),frequency:HD}),Xz=dB.extend({ftype:lA("simple_transistor"),transistor_type:Ze(["npn","pnp"])}),$z=dB.extend({ftype:lA("simple_test_point"),footprint_variant:Ze(["pad","through_hole"]).optional(),pad_shape:Ze(["rect","circle"]).optional(),pad_diameter:Zt([NA(),v()]).optional(),hole_diameter:Zt([NA(),v()]).optional(),width:Zt([NA(),v()]).optional(),height:Zt([NA(),v()]).optional()}),AX=dB.extend({ftype:lA("simple_mosfet"),channel_type:Ze(["n","p"]),mosfet_mode:Ze(["enhancement","depletion"])}),eX=dB.extend({ftype:lA("simple_switch")}),tX=xA({type:lA("source_project_metadata"),name:v().optional(),software_used_string:v().optional(),project_url:v().optional(),created_at:gxA.optional()}),lxA=xA({type:lA("source_missing_property_error"),source_missing_property_error_id:Ai("source_missing_property_error"),source_component_id:v(),property_name:v(),subcircuit_id:v().optional(),error_type:lA("source_missing_property_error").default("source_missing_property_error"),message:v()}).describe("The source code is missing a property"),QxA=xA({type:lA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Ai("source_failed_to_create_component_error"),error_type:lA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:v().optional(),subcircuit_id:v().optional(),parent_source_component_id:v().optional(),message:v(),pcb_center:xA({x:NA().optional(),y:NA().optional()}).optional(),schematic_center:xA({x:NA().optional(),y:NA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),iX=xA({type:lA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Ai("source_trace_not_connected_error"),error_type:lA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:v(),subcircuit_id:v().optional(),source_group_id:v().optional(),source_trace_id:v().optional(),connected_source_port_ids:fe(v()).optional(),selectors_not_found:fe(v()).optional()}).describe("Occurs when a source trace selector does not match any ports"),ExA=xA({type:lA("source_property_ignored_warning"),source_property_ignored_warning_id:Ai("source_property_ignored_warning"),source_component_id:v(),property_name:v(),subcircuit_id:v().optional(),error_type:lA("source_property_ignored_warning").default("source_property_ignored_warning"),message:v()}).describe("The source property was ignored"),oX=xA({type:lA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Ai("source_pin_missing_trace_warning"),warning_type:lA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:v(),source_component_id:v(),source_port_id:v(),subcircuit_id:v().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),hxA=dB.extend({ftype:lA("simple_voltage_probe")}),uxA=dB.extend({ftype:lA("interconnect")}),dxA=Zt([Jz,Yz,nT,cxA,Kz,BxA,Tz,qz,Pz,Oz,Wz,Zz,CxA,Vz,jz,zz,eX,Xz,$z,AX,ube,hxA,uxA,tX,lxA,QxA,iX,ExA,oX]),pxA=xA({type:lA("source_port"),pin_number:NA().optional(),port_hints:fe(v()).optional(),name:v(),source_port_id:v(),source_component_id:v().optional(),source_group_id:v().optional(),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),must_be_connected:te().optional()}),fxA=xA({type:lA("source_component_internal_connection"),source_component_internal_connection_id:v(),source_component_id:v(),source_port_ids:fe(v()),subcircuit_id:v().optional()}),yxA=xA({type:lA("source_trace"),source_trace_id:v(),connected_source_port_ids:fe(v()),connected_source_net_ids:fe(v()),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),max_length:NA().optional(),min_trace_thickness:NA().optional(),display_name:v().optional()}),mxA=xA({type:lA("source_group"),source_group_id:v(),subcircuit_id:v().optional(),parent_subcircuit_id:v().optional(),parent_source_group_id:v().optional(),is_subcircuit:te().optional(),show_as_schematic_box:te().optional(),name:v().optional(),was_automatically_named:te().optional()}),wxA=xA({type:lA("source_net"),source_net_id:v(),name:v(),member_source_group_ids:fe(v()),is_power:te().optional(),is_ground:te().optional(),is_digital_signal:te().optional(),is_analog_signal:te().optional(),is_positive_voltage_source:te().optional(),trace_width:NA().optional(),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional()}),DxA=xA({type:lA("source_board"),source_board_id:v(),source_group_id:v(),title:v().optional()}).describe("Defines a board in the source domain"),SxA=xA({type:lA("source_pcb_ground_plane"),source_pcb_ground_plane_id:v(),source_group_id:v(),source_net_id:v(),subcircuit_id:v().optional()}).describe("Defines a ground plane in the source domain"),z1=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],nX=Ze(z1),ss=nX.or(xA({name:nX})).transform(t=>typeof t=="string"?t:t.name),sm=Ze(["top","bottom"]),bxA=xA({type:lA("source_manually_placed_via"),source_manually_placed_via_id:v(),source_group_id:v(),source_net_id:v(),subcircuit_id:v().optional(),source_trace_id:v().optional()}).describe("Defines a via that is manually placed in the source domain"),xxA=xA({type:lA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Ai("source_pin_must_be_connected_error"),error_type:lA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:v(),source_component_id:v(),source_port_id:v(),subcircuit_id:v().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),sX=xA({type:lA("unknown_error_finding_part"),unknown_error_finding_part_id:Ai("unknown_error_finding_part"),error_type:lA("unknown_error_finding_part").default("unknown_error_finding_part"),message:v(),source_component_id:v().optional(),subcircuit_id:v().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),kxA=xA({type:lA("schematic_box"),schematic_component_id:v().optional(),width:Ie,height:Ie,is_dashed:te().default(!1),x:Ie,y:Ie,subcircuit_id:v().optional()}).describe("Draws a box on the schematic"),GxA=xA({type:lA("schematic_path"),schematic_component_id:v(),fill_color:Ze(["red","blue"]).optional(),is_filled:te().optional(),points:fe(co),subcircuit_id:v().optional()}),FxA=$r(xA({left_margin:VA.optional(),right_margin:VA.optional(),top_margin:VA.optional(),bottom_margin:VA.optional()})),_xA=xA({left_size:NA(),right_size:NA(),top_size:NA().optional(),bottom_size:NA().optional()}),RxA=xA({left_side:xA({pins:fe(NA()),direction:Ze(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:xA({pins:fe(NA()),direction:Ze(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:xA({pins:fe(NA()),direction:Ze(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:xA({pins:fe(NA()),direction:Ze(["left-to-right","right-to-left"]).optional()}).optional()}),NxA=Zt([_xA,RxA]),MxA=xA({type:lA("schematic_component"),size:Hz,center:co,source_component_id:v().optional(),schematic_component_id:v(),pin_spacing:VA.optional(),pin_styles:FxA.optional(),box_width:VA.optional(),symbol_name:v().optional(),port_arrangement:NxA.optional(),port_labels:$r(v()).optional(),symbol_display_value:v().optional(),subcircuit_id:v().optional(),schematic_group_id:v().optional(),is_schematic_group:te().optional(),source_group_id:v().optional(),is_box_with_pins:te().optional().default(!0)}),vxA=xA({type:lA("schematic_line"),schematic_line_id:Ai("schematic_line"),schematic_component_id:v(),x1:Ie,y1:Ie,x2:Ie,y2:Ie,stroke_width:Ie.nullable().optional(),color:v().default("#000000"),is_dashed:te().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled line on the schematic"),UxA=xA({type:lA("schematic_rect"),schematic_rect_id:Ai("schematic_rect"),schematic_component_id:v(),center:co,width:Ie,height:Ie,rotation:BI.default(0),stroke_width:Ie.nullable().optional(),color:v().default("#000000"),is_filled:te().default(!1),fill_color:v().optional(),is_dashed:te().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled rectangle on the schematic"),LxA=xA({type:lA("schematic_circle"),schematic_circle_id:Ai("schematic_circle"),schematic_component_id:v(),center:co,radius:Ie,stroke_width:Ie.nullable().optional(),color:v().default("#000000"),is_filled:te().default(!1),fill_color:v().optional(),is_dashed:te().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled circle on the schematic"),HxA=xA({type:lA("schematic_arc"),schematic_arc_id:Ai("schematic_arc"),schematic_component_id:v(),center:co,radius:Ie,start_angle_degrees:BI,end_angle_degrees:BI,direction:Ze(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:Ie.nullable().optional(),color:v().default("#000000"),is_dashed:te().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled arc on the schematic"),YxA=xA({type:lA("schematic_trace"),schematic_trace_id:v(),source_trace_id:v().optional(),junctions:fe(xA({x:NA(),y:NA()})),edges:fe(xA({from:xA({x:NA(),y:NA()}),to:xA({x:NA(),y:NA()}),is_crossing:te().optional(),from_schematic_port_id:v().optional(),to_schematic_port_id:v().optional()})),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional()}),dbe=Ze(["center","left","right","top","bottom"]),JxA=xA({type:lA("schematic_text"),schematic_component_id:v().optional(),schematic_text_id:v(),text:v(),font_size:NA().default(.18),position:xA({x:Ie,y:Ie}),rotation:NA().default(0),anchor:Zt([dbe.describe("legacy"),$k]).default("center"),color:v().default("#000000"),subcircuit_id:v().optional()}),KxA=xA({type:lA("schematic_port"),schematic_port_id:v(),source_port_id:v(),schematic_component_id:v().optional(),center:co,facing_direction:Ze(["up","down","left","right"]).optional(),distance_from_component_edge:NA().optional(),side_of_component:Ze(["top","bottom","left","right"]).optional(),true_ccw_index:NA().optional(),pin_number:NA().optional(),display_pin_label:v().optional(),subcircuit_id:v().optional(),is_connected:te().optional(),has_input_arrow:te().optional(),has_output_arrow:te().optional()}).describe("Defines a port on a schematic component"),TxA=xA({type:lA("schematic_net_label"),schematic_net_label_id:Ai("schematic_net_label"),schematic_trace_id:v().optional(),source_trace_id:v().optional(),source_net_id:v(),center:co,anchor_position:co.optional(),anchor_side:Ze(["top","bottom","left","right"]),text:v(),symbol_name:v().optional(),is_movable:te().optional(),subcircuit_id:v().optional()}),qxA=xA({type:lA("schematic_error"),schematic_error_id:v(),error_type:lA("schematic_port_not_found").default("schematic_port_not_found"),message:v(),subcircuit_id:v().optional()}).describe("Defines a schematic error on the schematic"),PxA=xA({type:lA("schematic_layout_error"),schematic_layout_error_id:Ai("schematic_layout_error"),error_type:lA("schematic_layout_error").default("schematic_layout_error"),message:v(),source_group_id:v(),schematic_group_id:v(),subcircuit_id:v().optional()}).describe("Error emitted when schematic layout fails for a group"),sT=xA({type:lA("schematic_debug_object"),label:v().optional(),subcircuit_id:v().optional()}),OxA=sT.extend({shape:lA("rect"),center:co,size:Hz}),WxA=sT.extend({shape:lA("line"),start:co,end:co}),ZxA=sT.extend({shape:lA("point"),center:co}),VxA=rE("shape",[OxA,WxA,ZxA]),jxA=xA({type:lA("schematic_voltage_probe"),schematic_voltage_probe_id:v(),source_component_id:v().optional(),name:v().optional(),position:co,schematic_trace_id:v(),voltage:z0.optional(),subcircuit_id:v().optional(),color:v().optional(),label_alignment:$k.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),rX=xA({type:lA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Ai("schematic_manual_edit_conflict_warning"),warning_type:lA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:v(),schematic_component_id:v(),schematic_group_id:v().optional(),subcircuit_id:v().optional(),source_component_id:v()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),zxA=xA({type:lA("schematic_group"),schematic_group_id:Ai("schematic_group"),source_group_id:v(),is_subcircuit:te().optional(),subcircuit_id:v().optional(),width:VA,height:VA,center:co,schematic_component_ids:fe(v()),show_as_schematic_box:te().optional(),name:v().optional(),description:v().optional()}).describe("Defines a group of components on the schematic"),XxA=xA({type:lA("schematic_table"),schematic_table_id:Ai("schematic_table"),anchor_position:co,column_widths:fe(Ie),row_heights:fe(Ie),cell_padding:Ie.optional(),border_width:Ie.optional(),subcircuit_id:v().optional(),schematic_component_id:v().optional(),anchor:$k.optional()}).describe("Defines a table on the schematic"),$xA=xA({type:lA("schematic_table_cell"),schematic_table_cell_id:Ai("schematic_table_cell"),schematic_table_id:v(),start_row_index:NA(),end_row_index:NA(),start_column_index:NA(),end_column_index:NA(),text:v().optional(),center:co,width:Ie,height:Ie,horizontal_align:Ze(["left","center","right"]).optional(),vertical_align:Ze(["top","middle","bottom"]).optional(),font_size:Ie.optional(),subcircuit_id:v().optional()}).describe("Defines a cell within a schematic_table"),AkA=xA({type:lA("schematic_sheet"),schematic_sheet_id:Ai("schematic_sheet"),name:v().optional(),subcircuit_id:v().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),ekA=xA({x:Ie,y:Ie,bulge:NA().optional()}),aX=xA({vertices:fe(ekA)}),tkA=xA({outer_ring:aX,inner_rings:fe(aX).default([])}),ikA=xA({x:Ie,y:Ie,via:te().optional(),via_to_layer:ss.optional()}),pbe=fe(ikA),sw=xA({x:Ie,y:Ie,via:te().optional(),to_layer:ss.optional(),trace_width:Ie.optional()}),okA=xA({type:lA("pcb_component"),pcb_component_id:Ai("pcb_component"),source_component_id:v(),center:co,layer:ss,rotation:BI,display_offset_x:v().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:v().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:VA,height:VA,do_not_place:te().optional(),subcircuit_id:v().optional(),pcb_group_id:v().optional(),position_mode:Ze(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:v().optional(),positioned_relative_to_pcb_board_id:v().optional(),obstructs_within_bounds:te().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),nkA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("circle"),hole_diameter:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),fbe=nkA.describe("Defines a circular hole on the PCB"),skA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("rect"),hole_width:NA(),hole_height:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),ybe=skA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square."),rkA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:Ze(["circle","square"]),hole_diameter:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),mbe=rkA.describe("Defines a circular or square hole on the PCB"),akA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("oval"),hole_width:NA(),hole_height:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),wbe=akA.describe("Defines an oval hole on the PCB"),gkA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("pill"),hole_width:NA(),hole_height:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Dbe=gkA.describe("Defines a pill-shaped hole on the PCB"),IkA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("rotated_pill"),hole_width:NA(),hole_height:NA(),x:Ie,y:Ie,ccw_rotation:BI,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Sbe=IkA.describe("Defines a rotated pill-shaped hole on the PCB"),ckA=rkA.or(akA).or(gkA).or(IkA).or(nkA).or(skA),bbe=xA({type:lA("pcb_plated_hole"),shape:lA("circle"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),outer_diameter:NA(),hole_diameter:NA(),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),xbe=xA({type:lA("pcb_plated_hole"),shape:Ze(["oval","pill"]),pcb_group_id:v().optional(),subcircuit_id:v().optional(),outer_width:NA(),outer_height:NA(),hole_width:NA(),hole_height:NA(),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,ccw_rotation:BI,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),kbe=xA({type:lA("pcb_plated_hole"),shape:lA("circular_hole_with_rect_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("circle"),pad_shape:lA("rect"),hole_diameter:NA(),rect_pad_width:NA(),rect_pad_height:NA(),rect_border_radius:NA().optional(),hole_offset_x:Ie.default(0),hole_offset_y:Ie.default(0),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),Gbe=xA({type:lA("pcb_plated_hole"),shape:lA("pill_hole_with_rect_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("pill"),pad_shape:lA("rect"),hole_width:NA(),hole_height:NA(),rect_pad_width:NA(),rect_pad_height:NA(),rect_border_radius:NA().optional(),hole_offset_x:Ie.default(0),hole_offset_y:Ie.default(0),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),Fbe=xA({type:lA("pcb_plated_hole"),shape:lA("rotated_pill_hole_with_rect_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("rotated_pill"),pad_shape:lA("rect"),hole_width:NA(),hole_height:NA(),hole_ccw_rotation:BI,rect_pad_width:NA(),rect_pad_height:NA(),rect_border_radius:NA().optional(),rect_ccw_rotation:BI,hole_offset_x:Ie.default(0),hole_offset_y:Ie.default(0),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),_be=xA({type:lA("pcb_plated_hole"),shape:lA("hole_with_polygon_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:Ze(["circle","oval","pill","rotated_pill"]),hole_diameter:NA().optional(),hole_width:NA().optional(),hole_height:NA().optional(),pad_outline:fe(xA({x:Ie,y:Ie})).min(3),hole_offset_x:Ie.default(0),hole_offset_y:Ie.default(0),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),BkA=Zt([bbe,xbe,kbe,Gbe,Fbe,_be]),CkA=xA({type:lA("pcb_port"),pcb_port_id:Ai("pcb_port"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),source_port_id:v(),pcb_component_id:v().optional(),x:Ie,y:Ie,layers:fe(ss),is_board_pinout:te().optional()}).describe("Defines a port on the PCB"),Rbe=xA({type:lA("pcb_smtpad"),shape:lA("circle"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,radius:NA(),layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Nbe=xA({type:lA("pcb_smtpad"),shape:lA("rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),rect_border_radius:NA().optional(),corner_radius:NA().optional(),layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Mbe=xA({type:lA("pcb_smtpad"),shape:lA("rotated_rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),rect_border_radius:NA().optional(),corner_radius:NA().optional(),ccw_rotation:BI,layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),lkA=xA({type:lA("pcb_smtpad"),shape:lA("pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),radius:NA(),layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),vbe=xA({type:lA("pcb_smtpad"),shape:lA("rotated_pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),radius:NA(),ccw_rotation:BI,layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Ube=xA({type:lA("pcb_smtpad"),shape:lA("polygon"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),points:fe(co),layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),QkA=rE("shape",[Rbe,Nbe,Mbe,vbe,lkA,Ube]).describe("Defines an SMT pad on the PCB"),Lbe=xA({type:lA("pcb_solder_paste"),shape:lA("circle"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,radius:NA(),layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Hbe=xA({type:lA("pcb_solder_paste"),shape:lA("rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Ybe=xA({type:lA("pcb_solder_paste"),shape:lA("pill"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),radius:NA(),layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Jbe=xA({type:lA("pcb_solder_paste"),shape:lA("rotated_rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),ccw_rotation:Ie,layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Kbe=xA({type:lA("pcb_solder_paste"),shape:lA("oval"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),EkA=Zt([Lbe,Hbe,Ybe,Jbe,Kbe]).describe("Defines solderpaste on the PCB"),hkA=xA({type:lA("pcb_text"),pcb_text_id:Ai("pcb_text"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),text:v(),center:co,layer:ss,width:VA,height:VA,lines:NA(),align:Ze(["bottom-left"])}).describe("Defines text on the PCB"),ukA=xA({route_type:lA("wire"),x:Ie,y:Ie,width:Ie,start_pcb_port_id:v().optional(),end_pcb_port_id:v().optional(),layer:ss}),dkA=xA({route_type:lA("via"),x:Ie,y:Ie,hole_diameter:Ie.optional(),outer_diameter:Ie.optional(),from_layer:v(),to_layer:v()}),gX=Zt([ukA,dkA]),pkA=xA({type:lA("pcb_trace"),source_trace_id:v().optional(),pcb_component_id:v().optional(),pcb_trace_id:Ai("pcb_trace"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),route_thickness_mode:Ze(["constant","interpolated"]).default("constant").optional(),route_order_index:NA().optional(),should_round_corners:te().optional(),trace_length:NA().optional(),highlight_color:v().optional(),route:fe(gX)}).describe("Defines a trace on the PCB"),fkA=xA({type:lA("pcb_trace_error"),pcb_trace_error_id:Ai("pcb_trace_error"),error_type:lA("pcb_trace_error").default("pcb_trace_error"),message:v(),center:co.optional(),pcb_trace_id:v(),source_trace_id:v(),pcb_component_ids:fe(v()),pcb_port_ids:fe(v()),subcircuit_id:v().optional()}).describe("Defines a trace error on the PCB"),ykA=xA({type:lA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Ai("pcb_trace_missing_error"),error_type:lA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:v(),center:co.optional(),source_trace_id:v(),pcb_component_ids:fe(v()),pcb_port_ids:fe(v()),subcircuit_id:v().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),mkA=xA({type:lA("pcb_port_not_matched_error"),pcb_error_id:Ai("pcb_error"),error_type:lA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:v(),pcb_component_ids:fe(v()),subcircuit_id:v().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),wkA=xA({type:lA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Ai("pcb_port_not_connected_error"),error_type:lA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:v(),pcb_port_ids:fe(v()),pcb_component_ids:fe(v()),subcircuit_id:v().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),DkA=xA({type:lA("pcb_net"),pcb_net_id:Ai("pcb_net"),source_net_id:v().optional(),highlight_color:v().optional()}).describe("Defines a net on the PCB"),SkA=xA({type:lA("pcb_via"),pcb_via_id:Ai("pcb_via"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),x:Ie,y:Ie,outer_diameter:Ie.default("0.6mm"),hole_diameter:Ie.default("0.25mm"),from_layer:ss.optional(),to_layer:ss.optional(),layers:fe(ss),pcb_trace_id:v().optional(),net_is_assignable:te().optional(),net_assigned:te().optional(),is_tented:te().optional()}).describe("Defines a via on the PCB"),bkA=xA({type:lA("pcb_board"),pcb_board_id:Ai("pcb_board"),pcb_panel_id:v().optional(),is_subcircuit:te().optional(),subcircuit_id:v().optional(),width:VA.optional(),height:VA.optional(),center:co,thickness:VA.optional().default(1.4),num_layers:NA().optional().default(4),outline:fe(co).optional(),shape:Ze(["rect","polygon"]).optional(),material:Ze(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),xkA=xA({type:lA("pcb_panel"),pcb_panel_id:Ai("pcb_panel"),width:VA,height:VA,center:co,covered_with_solder_mask:te().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),kkA=xA({type:lA("pcb_placement_error"),pcb_placement_error_id:Ai("pcb_placement_error"),error_type:lA("pcb_placement_error").default("pcb_placement_error"),message:v(),subcircuit_id:v().optional()}).describe("Defines a placement error on the PCB"),GkA=xA({type:lA("pcb_trace_hint"),pcb_trace_hint_id:Ai("pcb_trace_hint"),pcb_port_id:v(),pcb_component_id:v(),route:fe(sw),subcircuit_id:v().optional()}).describe("A hint that can be used during generation of a PCB trace"),FkA=xA({type:lA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Ai("pcb_silkscreen_line"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),stroke_width:Ie.default("0.1mm"),x1:Ie,y1:Ie,x2:Ie,y2:Ie,layer:sm}).describe("Defines a silkscreen line on the PCB"),_kA=xA({type:lA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Ai("pcb_silkscreen_path"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:sm,route:fe(co),stroke_width:VA}).describe("Defines a silkscreen path on the PCB"),RkA=xA({type:lA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Ai("pcb_silkscreen_text"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:Ie.default("0.2mm"),pcb_component_id:v(),text:v(),is_knockout:te().default(!1).optional(),knockout_padding:xA({left:VA,top:VA,bottom:VA,right:VA}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:NA().optional(),layer:ss,is_mirrored:te().default(!1).optional(),anchor_position:co.default({x:0,y:0}),anchor_alignment:$k.default("center")}).describe("Defines silkscreen text on the PCB"),NkA=xA({type:lA("pcb_copper_text"),pcb_copper_text_id:Ai("pcb_copper_text"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:Ie.default("0.2mm"),pcb_component_id:v(),text:v(),is_knockout:te().default(!1).optional(),knockout_padding:xA({left:VA,top:VA,bottom:VA,right:VA}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:NA().optional(),layer:ss,is_mirrored:te().default(!1).optional(),anchor_position:co.default({x:0,y:0}),anchor_alignment:$k.default("center")}).describe("Defines copper text on the PCB"),MkA=xA({type:lA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Ai("pcb_silkscreen_rect"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,width:VA,height:VA,layer:ss,stroke_width:VA.default("1mm"),corner_radius:VA.optional(),is_filled:te().default(!0).optional(),has_stroke:te().optional(),is_stroke_dashed:te().optional()}).describe("Defines a silkscreen rect on the PCB"),vkA=xA({type:lA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Ai("pcb_silkscreen_circle"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,radius:VA,layer:sm,stroke_width:VA.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),UkA=xA({type:lA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Ai("pcb_silkscreen_oval"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,radius_x:Ie,radius_y:Ie,layer:sm}).describe("Defines a silkscreen oval on the PCB"),LkA=xA({type:lA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Ai("pcb_fabrication_note_text"),subcircuit_id:v().optional(),pcb_group_id:v().optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:Ie.default("1mm"),pcb_component_id:v(),text:v(),layer:sm,anchor_position:co.default({x:0,y:0}),anchor_alignment:Ze(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:v().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),HkA=xA({type:lA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Ai("pcb_fabrication_note_path"),pcb_component_id:v(),subcircuit_id:v().optional(),layer:ss,route:fe(co),stroke_width:VA,color:v().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),YkA=xA({type:lA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Ai("pcb_fabrication_note_rect"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,width:VA,height:VA,layer:sm,stroke_width:VA.default("0.1mm"),corner_radius:VA.optional(),is_filled:te().optional(),has_stroke:te().optional(),is_stroke_dashed:te().optional(),color:v().optional()}).describe("Defines a fabrication note rectangle on the PCB"),JkA=xA({type:lA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Ai("pcb_fabrication_note_dimension"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:sm,from:co,to:co,text:v().optional(),text_ccw_rotation:NA().optional(),offset:VA.optional(),offset_distance:VA.optional(),offset_direction:xA({x:NA(),y:NA()}).optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:VA.default("1mm"),color:v().optional(),arrow_size:VA.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),KkA=xA({type:lA("pcb_note_text"),pcb_note_text_id:Ai("pcb_note_text"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:Ie.default("1mm"),text:v().optional(),anchor_position:co.default({x:0,y:0}),anchor_alignment:Ze(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:v().optional()}).describe("Defines a documentation note in text on the PCB"),TkA=xA({type:lA("pcb_note_rect"),pcb_note_rect_id:Ai("pcb_note_rect"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),text:v().optional(),center:co,width:VA,height:VA,stroke_width:VA.default("0.1mm"),corner_radius:VA.optional(),is_filled:te().optional(),has_stroke:te().optional(),is_stroke_dashed:te().optional(),color:v().optional()}).describe("Defines a rectangular documentation note on the PCB"),qkA=xA({type:lA("pcb_note_path"),pcb_note_path_id:Ai("pcb_note_path"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),text:v().optional(),route:fe(co),stroke_width:VA.default("0.1mm"),color:v().optional()}).describe("Defines a polyline documentation note on the PCB"),PkA=xA({type:lA("pcb_note_line"),pcb_note_line_id:Ai("pcb_note_line"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),text:v().optional(),x1:Ie,y1:Ie,x2:Ie,y2:Ie,stroke_width:Ie.default("0.1mm"),color:v().optional(),is_dashed:te().optional()}).describe("Defines a straight documentation note line on the PCB"),OkA=xA({type:lA("pcb_note_dimension"),pcb_note_dimension_id:Ai("pcb_note_dimension"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),from:co,to:co,text:v().optional(),text_ccw_rotation:NA().optional(),offset_distance:VA.optional(),offset_direction:xA({x:NA(),y:NA()}).optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:VA.default("1mm"),color:v().optional(),arrow_size:VA.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),WkA=xA({type:lA("pcb_footprint_overlap_error"),pcb_error_id:Ai("pcb_error"),error_type:lA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:v(),pcb_smtpad_ids:fe(v()).optional(),pcb_plated_hole_ids:fe(v()).optional(),pcb_hole_ids:fe(v()).optional(),pcb_keepout_ids:fe(v()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),ZkA=xA({type:lA("pcb_keepout"),shape:lA("rect"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,width:Ie,height:Ie,pcb_keepout_id:v(),layers:fe(v()),description:v().optional()}).or(xA({type:lA("pcb_keepout"),shape:lA("circle"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,radius:Ie,pcb_keepout_id:v(),layers:fe(v()),description:v().optional()})),rT=xA({type:lA("pcb_cutout"),pcb_cutout_id:Ai("pcb_cutout"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_board_id:v().optional(),pcb_panel_id:v().optional()}),VkA=rT.extend({shape:lA("rect"),center:co,width:VA,height:VA,rotation:BI.optional(),corner_radius:VA.optional()}),jkA=rT.extend({shape:lA("circle"),center:co,radius:VA}),zkA=rT.extend({shape:lA("polygon"),points:fe(co)}),XkA=rT.extend({shape:lA("path"),route:fe(co),slot_width:VA,slot_length:VA.optional(),space_between_slots:VA.optional(),slot_corner_radius:VA.optional()}),$kA=rE("shape",[VkA,jkA,zkA,XkA]).describe("Defines a cutout on the PCB, removing board material."),AGA=xA({type:lA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Ai("pcb_missing_footprint_error"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),error_type:lA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:v(),message:v()}).describe("Defines a missing footprint error on the PCB"),X1=xA({type:lA("external_footprint_load_error"),external_footprint_load_error_id:Ai("external_footprint_load_error"),pcb_component_id:v(),source_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),footprinter_string:v().optional(),error_type:lA("external_footprint_load_error").default("external_footprint_load_error"),message:v()}).describe("Defines an error when an external footprint fails to load"),IX=xA({type:lA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Ai("circuit_json_footprint_load_error"),pcb_component_id:v(),source_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),error_type:lA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:v(),circuit_json:fe(Yg()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),eGA=xA({type:lA("pcb_group"),pcb_group_id:Ai("pcb_group"),source_group_id:v(),is_subcircuit:te().optional(),subcircuit_id:v().optional(),width:VA.optional(),height:VA.optional(),center:co,display_offset_x:v().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:v().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:fe(co).optional(),anchor_position:co.optional(),anchor_alignment:$k.default("center"),position_mode:Ze(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:v().optional(),positioned_relative_to_pcb_board_id:v().optional(),pcb_component_ids:fe(v()),child_layout_mode:Ze(["packed","none"]).optional(),name:v().optional(),description:v().optional(),layout_mode:v().optional(),autorouter_configuration:xA({trace_clearance:VA}).optional(),autorouter_used_string:v().optional()}).describe("Defines a group of components on the PCB"),tGA=xA({type:lA("pcb_autorouting_error"),pcb_error_id:Ai("pcb_autorouting_error"),error_type:lA("pcb_autorouting_error").default("pcb_autorouting_error"),message:v(),subcircuit_id:v().optional()}).describe("The autorouting has failed to route a portion of the board"),cX=xA({type:lA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Ai("pcb_manual_edit_conflict_warning"),warning_type:lA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:v(),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),source_component_id:v()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),iGA=xA({type:lA("pcb_breakout_point"),pcb_breakout_point_id:Ai("pcb_breakout_point"),pcb_group_id:v(),subcircuit_id:v().optional(),source_trace_id:v().optional(),source_port_id:v().optional(),source_net_id:v().optional(),x:Ie,y:Ie}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),oGA=xA({type:lA("pcb_ground_plane"),pcb_ground_plane_id:Ai("pcb_ground_plane"),source_pcb_ground_plane_id:v(),source_net_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional()}).describe("Defines a ground plane on the PCB"),nGA=xA({type:lA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Ai("pcb_ground_plane_region"),pcb_ground_plane_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:ss,points:fe(co)}).describe("Defines a polygon region of a ground plane"),sGA=xA({type:lA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Ai("pcb_thermal_spoke"),pcb_ground_plane_id:v(),shape:v(),spoke_count:NA(),spoke_thickness:Ie,spoke_inner_diameter:Ie,spoke_outer_diameter:Ie,pcb_plated_hole_id:v().optional(),subcircuit_id:v().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),BX=xA({type:lA("pcb_copper_pour"),pcb_copper_pour_id:Ai("pcb_copper_pour"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:ss,source_net_id:v().optional(),covered_with_solder_mask:te().optional().default(!0)}),rGA=BX.extend({shape:lA("rect"),center:co,width:VA,height:VA,rotation:BI.optional()}),aGA=BX.extend({shape:lA("brep"),brep_shape:tkA}),gGA=BX.extend({shape:lA("polygon"),points:fe(co)}),IGA=rE("shape",[rGA,aGA,gGA]).describe("Defines a copper pour on the PCB."),cGA=xA({type:lA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Ai("pcb_component_outside_board_error"),error_type:lA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:v(),pcb_component_id:v(),pcb_board_id:v(),component_center:co,component_bounds:xA({min_x:NA(),max_x:NA(),min_y:NA(),max_y:NA()}),subcircuit_id:v().optional(),source_component_id:v().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),aT=xA({type:lA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Ai("pcb_component_invalid_layer_error"),error_type:lA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:v(),pcb_component_id:v().optional(),source_component_id:v(),layer:ss,subcircuit_id:v().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),BGA=xA({type:lA("pcb_via_clearance_error"),pcb_error_id:Ai("pcb_error"),error_type:lA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:v(),pcb_via_ids:fe(v()).min(2),minimum_clearance:Ie.optional(),actual_clearance:Ie.optional(),pcb_center:xA({x:NA().optional(),y:NA().optional()}).optional(),subcircuit_id:v().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),CGA=xA({type:lA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Ai("pcb_courtyard_rect"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,width:VA,height:VA,layer:sm,color:v().optional()}).describe("Defines a courtyard rectangle on the PCB"),lGA=xA({type:lA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Ai("pcb_courtyard_outline"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:sm,outline:fe(co).min(2),stroke_width:VA.default("0.1mm"),is_closed:te().optional(),is_stroke_dashed:te().optional(),color:v().optional()}).describe("Defines a courtyard outline on the PCB"),QGA=xA({type:lA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Ai("pcb_courtyard_polygon"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:sm,points:fe(co).min(3),color:v().optional()}).describe("Defines a courtyard polygon on the PCB"),EGA=xA({type:lA("cad_component"),cad_component_id:v(),pcb_component_id:v(),source_component_id:v(),position:IR,rotation:IR.optional(),size:IR.optional(),layer:ss.optional(),subcircuit_id:v().optional(),footprinter_string:v().optional(),model_obj_url:v().optional(),model_stl_url:v().optional(),model_3mf_url:v().optional(),model_gltf_url:v().optional(),model_glb_url:v().optional(),model_step_url:v().optional(),model_wrl_url:v().optional(),model_unit_to_mm_scale_factor:NA().optional(),model_jscad:Yg().optional(),show_as_translucent_model:te().optional()}).describe("Defines a component on the PCB"),hGA=Ze(["sinewave","square","triangle","sawtooth"]),Tbe=Zt([v(),NA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(NA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),uGA=xA({type:lA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:lA(!0).optional().default(!0),positive_source_port_id:v().optional(),negative_source_port_id:v().optional(),positive_source_net_id:v().optional(),negative_source_net_id:v().optional(),voltage:z0}).describe("Defines a DC voltage source for simulation"),dGA=xA({type:lA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:lA(!1),terminal1_source_port_id:v().optional(),terminal2_source_port_id:v().optional(),terminal1_source_net_id:v().optional(),terminal2_source_net_id:v().optional(),voltage:z0.optional(),frequency:HD.optional(),peak_to_peak_voltage:z0.optional(),wave_shape:hGA.optional(),phase:BI.optional(),duty_cycle:Tbe.optional()}).describe("Defines an AC voltage source for simulation"),pGA=Zt([uGA,dGA]).describe("Defines a voltage source for simulation"),fGA=Zt([lA("spice_dc_sweep"),lA("spice_dc_operating_point"),lA("spice_transient_analysis"),lA("spice_ac_analysis")]),yGA=xA({type:lA("simulation_experiment"),simulation_experiment_id:Ai("simulation_experiment"),name:v(),experiment_type:fGA,time_per_step:j1.optional(),start_time_ms:Tf.optional(),end_time_ms:Tf.optional()}).describe("Defines a simulation experiment configuration"),mGA=xA({type:lA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Ai("simulation_transient_voltage_graph"),simulation_experiment_id:v(),timestamps_ms:fe(NA()).optional(),voltage_levels:fe(NA()),source_component_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),time_per_step:j1,start_time_ms:Tf,end_time_ms:Tf,name:v().optional(),color:v().optional()}).describe("Stores voltage measurements over time for a simulation"),wGA=xA({type:lA("simulation_switch"),simulation_switch_id:Ai("simulation_switch"),source_component_id:v().optional(),closes_at:Tf.optional(),opens_at:Tf.optional(),starts_closed:te().optional(),switching_frequency:HD.optional()}).describe("Defines a switch for simulation timing control"),DGA=xA({type:lA("simulation_voltage_probe"),simulation_voltage_probe_id:Ai("simulation_voltage_probe"),source_component_id:v().optional(),name:v().optional(),signal_input_source_port_id:v().optional(),signal_input_source_net_id:v().optional(),reference_input_source_port_id:v().optional(),reference_input_source_net_id:v().optional(),subcircuit_id:v().optional(),color:v().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,o=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&o?A.addIssue({code:Wt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Wt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):o&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Wt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Wt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),SGA=xA({type:lA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Ai("simulation_unknown_experiment_error"),error_type:lA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:v(),simulation_experiment_id:v().optional(),subcircuit_id:v().optional()}).describe("An unknown error occurred during the simulation experiment."),bGA=Zt([yxA,pxA,fxA,dxA,wxA,mxA,Tz,Yz,nT,Kz,Jz,qz,Pz,Oz,Vz,jz,zz,eX,Xz,$z,AX,Zz,Wz,SxA,bxA,DxA,tX,iX,oX,xxA,sX,okA,ckA,AGA,X1,IX,cX,BkA,ZkA,CkA,DkA,hkA,pkA,SkA,QkA,EkA,bkA,xkA,eGA,GkA,FkA,_kA,RkA,NkA,MkA,vkA,UkA,fkA,ykA,kkA,mkA,wkA,BGA,HkA,LkA,YkA,JkA,KkA,TkA,qkA,PkA,OkA,tGA,WkA,iGA,$kA,oGA,nGA,sGA,IGA,cGA,aT,CGA,lGA,QGA,kxA,JxA,vxA,UxA,LxA,HxA,MxA,KxA,YxA,GxA,qxA,PxA,TxA,VxA,jxA,rX,zxA,AkA,XxA,$xA,EGA,pGA,yGA,mGA,wGA,DGA,SGA]),cR=bGA;const $1=Object.freeze(Object.defineProperty({__proto__:null,all_layers:z1,any_circuit_element:bGA,any_soup_element:cR,any_source_component:dxA,battery_capacity:IxA,brep_shape:tkA,cad_component:EGA,capacitance:gR,circuit_json_footprint_load_error:IX,current:Cbe,distance:Ie,duration_ms:j1,experiment_type:fGA,external_footprint_load_error:X1,frequency:HD,getZodPrefixedIdWithDefault:Ai,inductance:Lz,layer_ref:ss,layer_string:nX,length:VA,ms:Tf,ninePointAnchor:$k,pcb_autorouting_error:tGA,pcb_board:bkA,pcb_breakout_point:iGA,pcb_component:okA,pcb_component_invalid_layer_error:aT,pcb_component_outside_board_error:cGA,pcb_copper_pour:IGA,pcb_copper_pour_brep:aGA,pcb_copper_pour_polygon:gGA,pcb_copper_pour_rect:rGA,pcb_copper_text:NkA,pcb_courtyard_outline:lGA,pcb_courtyard_polygon:QGA,pcb_courtyard_rect:CGA,pcb_cutout:$kA,pcb_cutout_circle:jkA,pcb_cutout_path:XkA,pcb_cutout_polygon:zkA,pcb_cutout_rect:VkA,pcb_fabrication_note_dimension:JkA,pcb_fabrication_note_path:HkA,pcb_fabrication_note_rect:YkA,pcb_fabrication_note_text:LkA,pcb_footprint_overlap_error:WkA,pcb_ground_plane:oGA,pcb_ground_plane_region:nGA,pcb_group:eGA,pcb_hole:ckA,pcb_hole_circle_or_square_shape:mbe,pcb_hole_circle_shape:fbe,pcb_hole_oval_shape:wbe,pcb_hole_pill_shape:Dbe,pcb_hole_rect_shape:ybe,pcb_hole_rotated_pill_shape:Sbe,pcb_keepout:ZkA,pcb_manual_edit_conflict_warning:cX,pcb_missing_footprint_error:AGA,pcb_net:DkA,pcb_note_dimension:OkA,pcb_note_line:PkA,pcb_note_path:qkA,pcb_note_rect:TkA,pcb_note_text:KkA,pcb_panel:xkA,pcb_placement_error:kkA,pcb_plated_hole:BkA,pcb_port:CkA,pcb_port_not_connected_error:wkA,pcb_port_not_matched_error:mkA,pcb_route_hint:ikA,pcb_route_hints:pbe,pcb_silkscreen_circle:vkA,pcb_silkscreen_line:FkA,pcb_silkscreen_oval:UkA,pcb_silkscreen_path:_kA,pcb_silkscreen_rect:MkA,pcb_silkscreen_text:RkA,pcb_smtpad:QkA,pcb_smtpad_pill:lkA,pcb_solder_paste:EkA,pcb_text:hkA,pcb_thermal_spoke:sGA,pcb_trace:pkA,pcb_trace_error:fkA,pcb_trace_hint:GkA,pcb_trace_missing_error:ykA,pcb_trace_route_point:gX,pcb_trace_route_point_via:dkA,pcb_trace_route_point_wire:ukA,pcb_via:SkA,pcb_via_clearance_error:BGA,point:co,point3:IR,point_with_bulge:ekA,port_arrangement:NxA,position:Qbe,position3:Ebe,resistance:aR,ring:aX,rotation:BI,route_hint_point:sw,schematic_arc:HxA,schematic_box:kxA,schematic_circle:LxA,schematic_component:MxA,schematic_component_port_arrangement_by_sides:RxA,schematic_component_port_arrangement_by_size:_xA,schematic_debug_line:WxA,schematic_debug_object:VxA,schematic_debug_object_base:sT,schematic_debug_point:ZxA,schematic_debug_rect:OxA,schematic_error:qxA,schematic_group:zxA,schematic_layout_error:PxA,schematic_line:vxA,schematic_manual_edit_conflict_warning:rX,schematic_net_label:TxA,schematic_path:GxA,schematic_pin_styles:FxA,schematic_port:KxA,schematic_rect:UxA,schematic_sheet:AkA,schematic_table:XxA,schematic_table_cell:$xA,schematic_text:JxA,schematic_trace:YxA,schematic_voltage_probe:jxA,simulation_ac_voltage_source:dGA,simulation_dc_voltage_source:uGA,simulation_experiment:yGA,simulation_switch:wGA,simulation_transient_voltage_graph:mGA,simulation_unknown_experiment_error:SGA,simulation_voltage_probe:DGA,simulation_voltage_source:pGA,size:Hz,source_board:DxA,source_component_base:dB,source_component_internal_connection:fxA,source_failed_to_create_component_error:QxA,source_group:mxA,source_interconnect:uxA,source_manually_placed_via:bxA,source_missing_property_error:lxA,source_net:wxA,source_pcb_ground_plane:SxA,source_pin_missing_trace_warning:oX,source_pin_must_be_connected_error:xxA,source_port:pxA,source_project_metadata:tX,source_property_ignored_warning:ExA,source_simple_battery:Pz,source_simple_capacitor:Yz,source_simple_chip:Tz,source_simple_crystal:CxA,source_simple_diode:nT,source_simple_fiducial:cxA,source_simple_ground:BxA,source_simple_inductor:Oz,source_simple_led:Kz,source_simple_mosfet:AX,source_simple_pin_header:Vz,source_simple_pinout:jz,source_simple_potentiometer:Zz,source_simple_power_source:qz,source_simple_push_button:Wz,source_simple_resistor:Jz,source_simple_resonator:zz,source_simple_switch:eX,source_simple_test_point:$z,source_simple_transistor:Xz,source_simple_voltage_probe:hxA,source_trace:yxA,source_trace_not_connected_error:iX,supplier_name:oT,time:lbe,timestamp:gxA,unknown_error_finding_part:sX,visible_layer:sm,voltage:z0,wave_shape:hGA},Symbol.toStringTag,{value:"Module"}));function ge(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function qbe(t,A){return A.map(e=>ge(t,e))}function xGA(t){return{a:parseFloat(t.a),b:parseFloat(t.b),c:parseFloat(t.c),d:parseFloat(t.d),e:parseFloat(t.e),f:parseFloat(t.f)}}const Pbe=/^matrix\(\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*\)$/i;function gT(t){const A=t.match(Pbe);if(A===null||A.length<7)throw new Error(`'${t}' is not a matrix`);return{a:parseFloat(A[1]),b:parseFloat(A[2]),c:parseFloat(A[3]),d:parseFloat(A[4]),e:parseFloat(A[5]),f:parseFloat(A[6])}}function pg(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function X0(t){const{a:A,b:e,c:i,d:o,e:n,f:s}=t,r=A*o-e*i;return{a:o/r,b:e/-r,c:i/-r,d:A/r,e:(o*n-i*s)/-r,f:(e*n-A*s)/r}}function A2(t){return typeof t>"u"}function BR(t){return typeof t=="number"&&!Number.isNaN(t)&&Number.isFinite(t)}function Obe(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Wbe(t){return Obe(t)&&"a"in t&&BR(t.a)&&"b"in t&&BR(t.b)&&"c"in t&&BR(t.c)&&"d"in t&&BR(t.d)&&"e"in t&&BR(t.e)&&"f"in t&&BR(t.f)}function Wi(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function CR(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...o]=t,n=A(e,i);return CR(n,...o)}}}function Ji(...t){return CR(...t)}const{cos:Zbe,sin:Vbe,PI:jbe}=Math;function YI(t,A,e){const i=Zbe(t),o=Vbe(t),n={a:i,c:-o,e:0,b:o,d:i,f:0};return A2(A)||A2(e)?n:CR([Wi(A,e),n,Wi(-A,-e)])}function e2(t,A=void 0,e=void 0){return YI(t*jbe/180,A,e)}function ya(t,A=void 0,e=void 0,i=void 0){A2(A)&&(A=t);const o={a:t,c:0,e:0,b:0,d:A,f:0};return A2(e)||A2(i)?o:CR([Wi(e,i),o,Wi(-e,-i)])}function kGA(t,A){return{a:1,c:t,e:0,b:A,d:1,f:0}}const{tan:GGA}=Math;function FGA(t,A){return{a:1,c:GGA(t),e:0,b:GGA(A),d:1,f:0}}function CX(t,A){return FGA(t*Math.PI/180,A*Math.PI/180)}function zbe(t){return fu(t)}function _GA(t){return fu(t)}function fu(t){return`matrix(${t.a},${t.b},${t.c},${t.d},${t.e},${t.f})`}function RGA(t,A=1e10){return{a:Math.round(t.a*A)/A,b:Math.round(t.b*A)/A,c:Math.round(t.c*A)/A,d:Math.round(t.d*A)/A,e:Math.round(t.e*A)/A,f:Math.round(t.f*A)/A}}function NGA(t,A){const e=t[0].x!=null?t[0].x:t[0][0],i=t[0].y!=null?t[0].y:t[0][1],o=A[0].x!=null?A[0].x:A[0][0],n=A[0].y!=null?A[0].y:A[0][1],s=t[1].x!=null?t[1].x:t[1][0],r=t[1].y!=null?t[1].y:t[1][1],a=A[1].x!=null?A[1].x:A[1][0],g=A[1].y!=null?A[1].y:A[1][1],I=t[2].x!=null?t[2].x:t[2][0],c=t[2].y!=null?t[2].y:t[2][1],B=A[2].x!=null?A[2].x:A[2][0],C=A[2].y!=null?A[2].y:A[2][1],l={a:e-I,b:i-c,c:s-I,d:r-c,e:I,f:c},Q={a:o-B,b:n-C,c:a-B,d:g-C,e:B,f:C},E=X0(l),h=CR([Q,E]);return RGA(h)}function Xbe(t){return Array.isArray(t)?t.map(A):A(t);function A(e){switch(e.type){case"matrix":if("a"in e&&"b"in e&&"c"in e&&"d"in e&&"e"in e&&"f"in e)return xGA(e);throw new Error("MISSING_MANDATORY_PARAM");case"translate":if(!("tx"in e))throw new Error("MISSING_MANDATORY_PARAM");return"ty"in e?Wi(e.tx,e.ty):Wi(e.tx);case"scale":if(!("sx"in e))throw new Error("MISSING_MANDATORY_PARAM");return"sy"in e?ya(e.sx,e.sy):ya(e.sx);case"rotate":if(!("angle"in e))throw new Error("MISSING_MANDATORY_PARAM");return"cx"in e&&"cy"in e?e2(e.angle,e.cx,e.cy):e2(e.angle);case"skewX":if(!("angle"in e))throw new Error("MISSING_MANDATORY_PARAM");return CX(e.angle,0);case"skewY":if(!("angle"in e))throw new Error("MISSING_MANDATORY_PARAM");return CX(0,e.angle);case"shear":if(!("shx"in e&&"shy"in e))throw new Error("MISSING_MANDATORY_PARAM");return kGA(e.shx,e.shy);default:throw new Error("UNSUPPORTED_DESCRIPTOR")}}}function $be(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function lR(t,A,e,i){var o=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(o,lR.prototype),o.expected=A,o.found=e,o.location=i,o.name="SyntaxError",o}$be(lR,Error);function lX(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}lR.prototype.format=function(t){var A="Error: "+this.message;if(this.location){var e=null,i;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){e=t[i].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,n=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(o):o,s=this.location.source+":"+n.line+":"+n.column;if(e){var r=this.location.end,a=lX("",n.line.toString().length," "),g=e[o.line-1],I=o.line===r.line?r.column:g.length+1,c=I-o.column||1;A+=`
|
|
4039
|
+
}`;class vDe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(A,e,i){if(this.texture===null){const o=new Yc,n=A.properties.get(o);n.__webglTexture=e.texture,(e.depthNear!=i.depthNear||e.depthFar!=i.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=o}}getMesh(A){if(this.texture!==null&&this.mesh===null){const e=A.cameras[0].viewport,i=new Aw({vertexShader:NDe,fragmentShader:MDe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new on(new im(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}}class UDe extends Mk{constructor(A,e){super();const i=this;let o=null,n=1,s=null,r="local-floor",a=1,g=null,I=null,c=null,B=null,C=null,l=null;const Q=new vDe,E=e.getContextAttributes();let h=null,u=null;const d=[],f=[],D=new Io;let w=null;const x=new sE;x.layers.enable(1),x.viewport=new ug;const b=new sE;b.layers.enable(2),b.viewport=new ug;const F=[x,b],k=new _De;k.layers.enable(1),k.layers.enable(2);let U=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(pA){let bA=d[pA];return bA===void 0&&(bA=new tz,d[pA]=bA),bA.getTargetRaySpace()},this.getControllerGrip=function(pA){let bA=d[pA];return bA===void 0&&(bA=new tz,d[pA]=bA),bA.getGripSpace()},this.getHand=function(pA){let bA=d[pA];return bA===void 0&&(bA=new tz,d[pA]=bA),bA.getHandSpace()};function J(pA){const bA=f.indexOf(pA.inputSource);if(bA===-1)return;const vA=d[bA];vA!==void 0&&(vA.update(pA.inputSource,pA.frame,g||s),vA.dispatchEvent({type:pA.type,data:pA.inputSource}))}function P(){o.removeEventListener("select",J),o.removeEventListener("selectstart",J),o.removeEventListener("selectend",J),o.removeEventListener("squeeze",J),o.removeEventListener("squeezestart",J),o.removeEventListener("squeezeend",J),o.removeEventListener("end",P),o.removeEventListener("inputsourceschange",T);for(let pA=0;pA<d.length;pA++){const bA=f[pA];bA!==null&&(f[pA]=null,d[pA].disconnect(bA))}U=null,N=null,Q.reset(),A.setRenderTarget(h),C=null,B=null,c=null,o=null,u=null,gA.stop(),i.isPresenting=!1,A.setPixelRatio(w),A.setSize(D.width,D.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(pA){n=pA,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(pA){r=pA,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return g||s},this.setReferenceSpace=function(pA){g=pA},this.getBaseLayer=function(){return B!==null?B:C},this.getBinding=function(){return c},this.getFrame=function(){return l},this.getSession=function(){return o},this.setSession=async function(pA){if(o=pA,o!==null){if(h=A.getRenderTarget(),o.addEventListener("select",J),o.addEventListener("selectstart",J),o.addEventListener("selectend",J),o.addEventListener("squeeze",J),o.addEventListener("squeezestart",J),o.addEventListener("squeezeend",J),o.addEventListener("end",P),o.addEventListener("inputsourceschange",T),E.xrCompatible!==!0&&await e.makeXRCompatible(),w=A.getPixelRatio(),A.getSize(D),o.renderState.layers===void 0){const bA={antialias:E.antialias,alpha:!0,depth:E.depth,stencil:E.stencil,framebufferScaleFactor:n};C=new XRWebGLLayer(o,e,bA),o.updateRenderState({baseLayer:C}),A.setPixelRatio(1),A.setSize(C.framebufferWidth,C.framebufferHeight,!1),u=new vk(C.framebufferWidth,C.framebufferHeight,{format:Z0,type:Qb,colorSpace:A.outputColorSpace,stencilBuffer:E.stencil})}else{let bA=null,vA=null,MA=null;E.depth&&(MA=E.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,bA=E.stencil?m_:y_,vA=E.stencil?f_:p_);const qA={colorFormat:e.RGBA8,depthFormat:MA,scaleFactor:n};c=new XRWebGLBinding(o,e),B=c.createProjectionLayer(qA),o.updateRenderState({layers:[B]}),A.setPixelRatio(1),A.setSize(B.textureWidth,B.textureHeight,!1),u=new vk(B.textureWidth,B.textureHeight,{format:Z0,type:Qb,depthTexture:new PSA(B.textureWidth,B.textureHeight,vA,void 0,void 0,void 0,void 0,void 0,void 0,bA),stencilBuffer:E.stencil,colorSpace:A.outputColorSpace,samples:E.antialias?4:0,resolveDepthBuffer:B.ignoreDepthValues===!1})}u.isXRRenderTarget=!0,this.setFoveation(a),g=null,s=await o.requestReferenceSpace(r),gA.setContext(o),gA.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(o!==null)return o.environmentBlendMode};function T(pA){for(let bA=0;bA<pA.removed.length;bA++){const vA=pA.removed[bA],MA=f.indexOf(vA);MA>=0&&(f[MA]=null,d[MA].disconnect(vA))}for(let bA=0;bA<pA.added.length;bA++){const vA=pA.added[bA];let MA=f.indexOf(vA);if(MA===-1){for(let CA=0;CA<d.length;CA++)if(CA>=f.length){f.push(vA),MA=CA;break}else if(f[CA]===null){f[CA]=vA,MA=CA;break}if(MA===-1)break}const qA=d[MA];qA&&qA.connect(vA)}}const O=new _e,W=new _e;function $(pA,bA,vA){O.setFromMatrixPosition(bA.matrixWorld),W.setFromMatrixPosition(vA.matrixWorld);const MA=O.distanceTo(W),qA=bA.projectionMatrix.elements,CA=vA.projectionMatrix.elements,mA=qA[14]/(qA[10]-1),uA=qA[14]/(qA[10]+1),PA=(qA[9]+1)/qA[5],ee=(qA[9]-1)/qA[5],Be=(qA[8]-1)/qA[0],yA=(CA[8]+1)/CA[0],WA=mA*Be,KA=mA*yA,JA=MA/(-Be+yA),jA=JA*-Be;bA.matrixWorld.decompose(pA.position,pA.quaternion,pA.scale),pA.translateX(jA),pA.translateZ(JA),pA.matrixWorld.compose(pA.position,pA.quaternion,pA.scale),pA.matrixWorldInverse.copy(pA.matrixWorld).invert();const GA=mA+JA,SA=uA+JA,_A=WA-jA,FA=KA+(MA-jA),TA=PA*uA/SA*GA,OA=ee*uA/SA*GA;pA.projectionMatrix.makePerspective(_A,FA,TA,OA,GA,SA),pA.projectionMatrixInverse.copy(pA.projectionMatrix).invert()}function oA(pA,bA){bA===null?pA.matrixWorld.copy(pA.matrix):pA.matrixWorld.multiplyMatrices(bA.matrixWorld,pA.matrix),pA.matrixWorldInverse.copy(pA.matrixWorld).invert()}this.updateCamera=function(pA){if(o===null)return;Q.texture!==null&&(pA.near=Q.depthNear,pA.far=Q.depthFar),k.near=b.near=x.near=pA.near,k.far=b.far=x.far=pA.far,(U!==k.near||N!==k.far)&&(o.updateRenderState({depthNear:k.near,depthFar:k.far}),U=k.near,N=k.far,x.near=U,x.far=N,b.near=U,b.far=N,x.updateProjectionMatrix(),b.updateProjectionMatrix(),pA.updateProjectionMatrix());const bA=pA.parent,vA=k.cameras;oA(k,bA);for(let MA=0;MA<vA.length;MA++)oA(vA[MA],bA);vA.length===2?$(k,x,b):k.projectionMatrix.copy(x.projectionMatrix),IA(pA,k,bA)};function IA(pA,bA,vA){vA===null?pA.matrix.copy(bA.matrixWorld):(pA.matrix.copy(vA.matrixWorld),pA.matrix.invert(),pA.matrix.multiply(bA.matrixWorld)),pA.matrix.decompose(pA.position,pA.quaternion,pA.scale),pA.updateMatrixWorld(!0),pA.projectionMatrix.copy(bA.projectionMatrix),pA.projectionMatrixInverse.copy(bA.projectionMatrixInverse),pA.isPerspectiveCamera&&(pA.fov=x_*2*Math.atan(1/pA.projectionMatrix.elements[5]),pA.zoom=1)}this.getCamera=function(){return k},this.getFoveation=function(){if(!(B===null&&C===null))return a},this.setFoveation=function(pA){a=pA,B!==null&&(B.fixedFoveation=pA),C!==null&&C.fixedFoveation!==void 0&&(C.fixedFoveation=pA)},this.hasDepthSensing=function(){return Q.texture!==null},this.getDepthSensingMesh=function(){return Q.getMesh(k)};let tA=null;function sA(pA,bA){if(I=bA.getViewerPose(g||s),l=bA,I!==null){const vA=I.views;C!==null&&(A.setRenderTargetFramebuffer(u,C.framebuffer),A.setRenderTarget(u));let MA=!1;vA.length!==k.cameras.length&&(k.cameras.length=0,MA=!0);for(let CA=0;CA<vA.length;CA++){const mA=vA[CA];let uA=null;if(C!==null)uA=C.getViewport(mA);else{const ee=c.getViewSubImage(B,mA);uA=ee.viewport,CA===0&&(A.setRenderTargetTextures(u,ee.colorTexture,B.ignoreDepthValues?void 0:ee.depthStencilTexture),A.setRenderTarget(u))}let PA=F[CA];PA===void 0&&(PA=new sE,PA.layers.enable(CA),PA.viewport=new ug,F[CA]=PA),PA.matrix.fromArray(mA.transform.matrix),PA.matrix.decompose(PA.position,PA.quaternion,PA.scale),PA.projectionMatrix.fromArray(mA.projectionMatrix),PA.projectionMatrixInverse.copy(PA.projectionMatrix).invert(),PA.viewport.set(uA.x,uA.y,uA.width,uA.height),CA===0&&(k.matrix.copy(PA.matrix),k.matrix.decompose(k.position,k.quaternion,k.scale)),MA===!0&&k.cameras.push(PA)}const qA=o.enabledFeatures;if(qA&&qA.includes("depth-sensing")){const CA=c.getDepthInformation(vA[0]);CA&&CA.isValid&&CA.texture&&Q.init(A,CA,o.renderState)}}for(let vA=0;vA<d.length;vA++){const MA=f[vA],qA=d[vA];MA!==null&&qA!==void 0&&qA.update(MA,bA,g||s)}tA&&tA(pA,bA),bA.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:bA}),l=null}const gA=new LSA;gA.setAnimationLoop(sA),this.setAnimationLoop=function(pA){tA=pA},this.dispose=function(){}}}const qk=new Np,LDe=new os;function HDe(t,A){function e(E,h){E.matrixAutoUpdate===!0&&E.updateMatrix(),h.value.copy(E.matrix)}function i(E,h){h.color.getRGB(E.fogColor.value,_SA(t)),h.isFog?(E.fogNear.value=h.near,E.fogFar.value=h.far):h.isFogExp2&&(E.fogDensity.value=h.density)}function o(E,h,u,d,f){h.isMeshBasicMaterial||h.isMeshLambertMaterial?n(E,h):h.isMeshToonMaterial?(n(E,h),c(E,h)):h.isMeshPhongMaterial?(n(E,h),I(E,h)):h.isMeshStandardMaterial?(n(E,h),B(E,h),h.isMeshPhysicalMaterial&&C(E,h,f)):h.isMeshMatcapMaterial?(n(E,h),l(E,h)):h.isMeshDepthMaterial?n(E,h):h.isMeshDistanceMaterial?(n(E,h),Q(E,h)):h.isMeshNormalMaterial?n(E,h):h.isLineBasicMaterial?(s(E,h),h.isLineDashedMaterial&&r(E,h)):h.isPointsMaterial?a(E,h,u,d):h.isSpriteMaterial?g(E,h):h.isShadowMaterial?(E.color.value.copy(h.color),E.opacity.value=h.opacity):h.isShaderMaterial&&(h.uniformsNeedUpdate=!1)}function n(E,h){E.opacity.value=h.opacity,h.color&&E.diffuse.value.copy(h.color),h.emissive&&E.emissive.value.copy(h.emissive).multiplyScalar(h.emissiveIntensity),h.map&&(E.map.value=h.map,e(h.map,E.mapTransform)),h.alphaMap&&(E.alphaMap.value=h.alphaMap,e(h.alphaMap,E.alphaMapTransform)),h.bumpMap&&(E.bumpMap.value=h.bumpMap,e(h.bumpMap,E.bumpMapTransform),E.bumpScale.value=h.bumpScale,h.side===rh&&(E.bumpScale.value*=-1)),h.normalMap&&(E.normalMap.value=h.normalMap,e(h.normalMap,E.normalMapTransform),E.normalScale.value.copy(h.normalScale),h.side===rh&&E.normalScale.value.negate()),h.displacementMap&&(E.displacementMap.value=h.displacementMap,e(h.displacementMap,E.displacementMapTransform),E.displacementScale.value=h.displacementScale,E.displacementBias.value=h.displacementBias),h.emissiveMap&&(E.emissiveMap.value=h.emissiveMap,e(h.emissiveMap,E.emissiveMapTransform)),h.specularMap&&(E.specularMap.value=h.specularMap,e(h.specularMap,E.specularMapTransform)),h.alphaTest>0&&(E.alphaTest.value=h.alphaTest);const u=A.get(h),d=u.envMap,f=u.envMapRotation;d&&(E.envMap.value=d,qk.copy(f),qk.x*=-1,qk.y*=-1,qk.z*=-1,d.isCubeTexture&&d.isRenderTargetTexture===!1&&(qk.y*=-1,qk.z*=-1),E.envMapRotation.value.setFromMatrix4(LDe.makeRotationFromEuler(qk)),E.flipEnvMap.value=d.isCubeTexture&&d.isRenderTargetTexture===!1?-1:1,E.reflectivity.value=h.reflectivity,E.ior.value=h.ior,E.refractionRatio.value=h.refractionRatio),h.lightMap&&(E.lightMap.value=h.lightMap,E.lightMapIntensity.value=h.lightMapIntensity,e(h.lightMap,E.lightMapTransform)),h.aoMap&&(E.aoMap.value=h.aoMap,E.aoMapIntensity.value=h.aoMapIntensity,e(h.aoMap,E.aoMapTransform))}function s(E,h){E.diffuse.value.copy(h.color),E.opacity.value=h.opacity,h.map&&(E.map.value=h.map,e(h.map,E.mapTransform))}function r(E,h){E.dashSize.value=h.dashSize,E.totalSize.value=h.dashSize+h.gapSize,E.scale.value=h.scale}function a(E,h,u,d){E.diffuse.value.copy(h.color),E.opacity.value=h.opacity,E.size.value=h.size*u,E.scale.value=d*.5,h.map&&(E.map.value=h.map,e(h.map,E.uvTransform)),h.alphaMap&&(E.alphaMap.value=h.alphaMap,e(h.alphaMap,E.alphaMapTransform)),h.alphaTest>0&&(E.alphaTest.value=h.alphaTest)}function g(E,h){E.diffuse.value.copy(h.color),E.opacity.value=h.opacity,E.rotation.value=h.rotation,h.map&&(E.map.value=h.map,e(h.map,E.mapTransform)),h.alphaMap&&(E.alphaMap.value=h.alphaMap,e(h.alphaMap,E.alphaMapTransform)),h.alphaTest>0&&(E.alphaTest.value=h.alphaTest)}function I(E,h){E.specular.value.copy(h.specular),E.shininess.value=Math.max(h.shininess,1e-4)}function c(E,h){h.gradientMap&&(E.gradientMap.value=h.gradientMap)}function B(E,h){E.metalness.value=h.metalness,h.metalnessMap&&(E.metalnessMap.value=h.metalnessMap,e(h.metalnessMap,E.metalnessMapTransform)),E.roughness.value=h.roughness,h.roughnessMap&&(E.roughnessMap.value=h.roughnessMap,e(h.roughnessMap,E.roughnessMapTransform)),h.envMap&&(E.envMapIntensity.value=h.envMapIntensity)}function C(E,h,u){E.ior.value=h.ior,h.sheen>0&&(E.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),E.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(E.sheenColorMap.value=h.sheenColorMap,e(h.sheenColorMap,E.sheenColorMapTransform)),h.sheenRoughnessMap&&(E.sheenRoughnessMap.value=h.sheenRoughnessMap,e(h.sheenRoughnessMap,E.sheenRoughnessMapTransform))),h.clearcoat>0&&(E.clearcoat.value=h.clearcoat,E.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(E.clearcoatMap.value=h.clearcoatMap,e(h.clearcoatMap,E.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(E.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,e(h.clearcoatRoughnessMap,E.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(E.clearcoatNormalMap.value=h.clearcoatNormalMap,e(h.clearcoatNormalMap,E.clearcoatNormalMapTransform),E.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===rh&&E.clearcoatNormalScale.value.negate())),h.dispersion>0&&(E.dispersion.value=h.dispersion),h.iridescence>0&&(E.iridescence.value=h.iridescence,E.iridescenceIOR.value=h.iridescenceIOR,E.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],E.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(E.iridescenceMap.value=h.iridescenceMap,e(h.iridescenceMap,E.iridescenceMapTransform)),h.iridescenceThicknessMap&&(E.iridescenceThicknessMap.value=h.iridescenceThicknessMap,e(h.iridescenceThicknessMap,E.iridescenceThicknessMapTransform))),h.transmission>0&&(E.transmission.value=h.transmission,E.transmissionSamplerMap.value=u.texture,E.transmissionSamplerSize.value.set(u.width,u.height),h.transmissionMap&&(E.transmissionMap.value=h.transmissionMap,e(h.transmissionMap,E.transmissionMapTransform)),E.thickness.value=h.thickness,h.thicknessMap&&(E.thicknessMap.value=h.thicknessMap,e(h.thicknessMap,E.thicknessMapTransform)),E.attenuationDistance.value=h.attenuationDistance,E.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(E.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(E.anisotropyMap.value=h.anisotropyMap,e(h.anisotropyMap,E.anisotropyMapTransform))),E.specularIntensity.value=h.specularIntensity,E.specularColor.value.copy(h.specularColor),h.specularColorMap&&(E.specularColorMap.value=h.specularColorMap,e(h.specularColorMap,E.specularColorMapTransform)),h.specularIntensityMap&&(E.specularIntensityMap.value=h.specularIntensityMap,e(h.specularIntensityMap,E.specularIntensityMapTransform))}function l(E,h){h.matcap&&(E.matcap.value=h.matcap)}function Q(E,h){const u=A.get(h).light;E.referencePosition.value.setFromMatrixPosition(u.matrixWorld),E.nearDistance.value=u.shadow.camera.near,E.farDistance.value=u.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:o}}function YDe(t,A,e,i){let o={},n={},s=[];const r=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function a(u,d){const f=d.program;i.uniformBlockBinding(u,f)}function g(u,d){let f=o[u.id];f===void 0&&(l(u),f=I(u),o[u.id]=f,u.addEventListener("dispose",E));const D=d.program;i.updateUBOMapping(u,D);const w=A.render.frame;n[u.id]!==w&&(B(u),n[u.id]=w)}function I(u){const d=c();u.__bindingPointIndex=d;const f=t.createBuffer(),D=u.__size,w=u.usage;return t.bindBuffer(t.UNIFORM_BUFFER,f),t.bufferData(t.UNIFORM_BUFFER,D,w),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,d,f),f}function c(){for(let u=0;u<r;u++)if(s.indexOf(u)===-1)return s.push(u),u;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function B(u){const d=o[u.id],f=u.uniforms,D=u.__cache;t.bindBuffer(t.UNIFORM_BUFFER,d);for(let w=0,x=f.length;w<x;w++){const b=Array.isArray(f[w])?f[w]:[f[w]];for(let F=0,k=b.length;F<k;F++){const U=b[F];if(C(U,w,F,D)===!0){const N=U.__offset,J=Array.isArray(U.value)?U.value:[U.value];let P=0;for(let T=0;T<J.length;T++){const O=J[T],W=Q(O);typeof O=="number"||typeof O=="boolean"?(U.__data[0]=O,t.bufferSubData(t.UNIFORM_BUFFER,N+P,U.__data)):O.isMatrix3?(U.__data[0]=O.elements[0],U.__data[1]=O.elements[1],U.__data[2]=O.elements[2],U.__data[3]=0,U.__data[4]=O.elements[3],U.__data[5]=O.elements[4],U.__data[6]=O.elements[5],U.__data[7]=0,U.__data[8]=O.elements[6],U.__data[9]=O.elements[7],U.__data[10]=O.elements[8],U.__data[11]=0):(O.toArray(U.__data,P),P+=W.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,N,U.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function C(u,d,f,D){const w=u.value,x=d+"_"+f;if(D[x]===void 0)return typeof w=="number"||typeof w=="boolean"?D[x]=w:D[x]=w.clone(),!0;{const b=D[x];if(typeof w=="number"||typeof w=="boolean"){if(b!==w)return D[x]=w,!0}else if(b.equals(w)===!1)return b.copy(w),!0}return!1}function l(u){const d=u.uniforms;let f=0;const D=16;for(let x=0,b=d.length;x<b;x++){const F=Array.isArray(d[x])?d[x]:[d[x]];for(let k=0,U=F.length;k<U;k++){const N=F[k],J=Array.isArray(N.value)?N.value:[N.value];for(let P=0,T=J.length;P<T;P++){const O=J[P],W=Q(O),$=f%D;$!==0&&D-$<W.boundary&&(f+=D-$),N.__data=new Float32Array(W.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=f,f+=W.storage}}}const w=f%D;return w>0&&(f+=D-w),u.__size=f,u.__cache={},this}function Q(u){const d={boundary:0,storage:0};return typeof u=="number"||typeof u=="boolean"?(d.boundary=4,d.storage=4):u.isVector2?(d.boundary=8,d.storage=8):u.isVector3||u.isColor?(d.boundary=16,d.storage=12):u.isVector4?(d.boundary=16,d.storage=16):u.isMatrix3?(d.boundary=48,d.storage=48):u.isMatrix4?(d.boundary=64,d.storage=64):u.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",u),d}function E(u){const d=u.target;d.removeEventListener("dispose",E);const f=s.indexOf(d.__bindingPointIndex);s.splice(f,1),t.deleteBuffer(o[d.id]),delete o[d.id],delete n[d.id]}function h(){for(const u in o)t.deleteBuffer(o[u]);s=[],o={},n={}}return{bind:a,update:g,dispose:h}}class kK{constructor(A={}){const{canvas:e=E0e(),context:i=null,depth:o=!0,stencil:n=!1,alpha:s=!1,antialias:r=!1,premultipliedAlpha:a=!0,preserveDrawingBuffer:g=!1,powerPreference:I="default",failIfMajorPerformanceCaveat:c=!1}=A;this.isWebGLRenderer=!0;let B;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");B=i.getContextAttributes().alpha}else B=s;const C=new Uint32Array(4),l=new Int32Array(4);let Q=null,E=null;const h=[],u=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Wy,this.toneMapping=lb,this.toneMappingExposure=1;const d=this;let f=!1,D=0,w=0,x=null,b=-1,F=null;const k=new ug,U=new ug;let N=null;const J=new Li(0);let P=0,T=e.width,O=e.height,W=1,$=null,oA=null;const IA=new ug(0,0,T,O),tA=new ug(0,0,T,O);let sA=!1;const gA=new Oj;let pA=!1,bA=!1;const vA=new os,MA=new _e,qA={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let CA=!1;function mA(){return x===null?W:1}let uA=i;function PA(Qe,Le){return e.getContext(Qe,Le)}try{const Qe={alpha:!0,depth:o,stencil:n,antialias:r,premultipliedAlpha:a,preserveDrawingBuffer:g,powerPreference:I,failIfMajorPerformanceCaveat:c};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${VJ}`),e.addEventListener("webglcontextlost",ae,!1),e.addEventListener("webglcontextrestored",Ce,!1),e.addEventListener("webglcontextcreationerror",me,!1),uA===null){const Le="webgl2";if(uA=PA(Le,Qe),uA===null)throw PA(Le)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(Qe){throw console.error("THREE.WebGLRenderer: "+Qe.message),Qe}let ee,Be,yA,WA,KA,JA,jA,GA,SA,_A,FA,TA,OA,oe,DA,BA,QA,YA,se,he,De,Fe,Xe,Ve;function lt(){ee=new zme(uA),ee.init(),Fe=new FDe(uA,ee),Be=new Pme(uA,ee,A,Fe),yA=new kDe(uA),WA=new Awe(uA),KA=new hDe,JA=new GDe(uA,ee,yA,KA,Be,Fe,WA),jA=new Wme(d),GA=new jme(d),SA=new J0e(uA),Xe=new Tme(uA,SA),_A=new Xme(uA,SA,WA,Xe),FA=new twe(uA,_A,SA,WA),se=new ewe(uA,Be,JA),BA=new Ome(KA),TA=new EDe(d,jA,GA,ee,Be,Xe,BA),OA=new HDe(d,KA),oe=new dDe,DA=new DDe(ee),YA=new Kme(d,jA,GA,yA,FA,B,a),QA=new xDe(d,FA,Be),Ve=new YDe(uA,WA,Be,yA),he=new qme(uA,ee,WA),De=new $me(uA,ee,WA),WA.programs=TA.programs,d.capabilities=Be,d.extensions=ee,d.properties=KA,d.renderLists=oe,d.shadowMap=QA,d.state=yA,d.info=WA}lt();const EA=new UDe(d,uA);this.xr=EA,this.getContext=function(){return uA},this.getContextAttributes=function(){return uA.getContextAttributes()},this.forceContextLoss=function(){const Qe=ee.get("WEBGL_lose_context");Qe&&Qe.loseContext()},this.forceContextRestore=function(){const Qe=ee.get("WEBGL_lose_context");Qe&&Qe.restoreContext()},this.getPixelRatio=function(){return W},this.setPixelRatio=function(Qe){Qe!==void 0&&(W=Qe,this.setSize(T,O,!1))},this.getSize=function(Qe){return Qe.set(T,O)},this.setSize=function(Qe,Le,$e=!0){if(EA.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}T=Qe,O=Le,e.width=Math.floor(Qe*W),e.height=Math.floor(Le*W),$e===!0&&(e.style.width=Qe+"px",e.style.height=Le+"px"),this.setViewport(0,0,Qe,Le)},this.getDrawingBufferSize=function(Qe){return Qe.set(T*W,O*W).floor()},this.setDrawingBufferSize=function(Qe,Le,$e){T=Qe,O=Le,W=$e,e.width=Math.floor(Qe*$e),e.height=Math.floor(Le*$e),this.setViewport(0,0,Qe,Le)},this.getCurrentViewport=function(Qe){return Qe.copy(k)},this.getViewport=function(Qe){return Qe.copy(IA)},this.setViewport=function(Qe,Le,$e,ze){Qe.isVector4?IA.set(Qe.x,Qe.y,Qe.z,Qe.w):IA.set(Qe,Le,$e,ze),yA.viewport(k.copy(IA).multiplyScalar(W).round())},this.getScissor=function(Qe){return Qe.copy(tA)},this.setScissor=function(Qe,Le,$e,ze){Qe.isVector4?tA.set(Qe.x,Qe.y,Qe.z,Qe.w):tA.set(Qe,Le,$e,ze),yA.scissor(U.copy(tA).multiplyScalar(W).round())},this.getScissorTest=function(){return sA},this.setScissorTest=function(Qe){yA.setScissorTest(sA=Qe)},this.setOpaqueSort=function(Qe){$=Qe},this.setTransparentSort=function(Qe){oA=Qe},this.getClearColor=function(Qe){return Qe.copy(YA.getClearColor())},this.setClearColor=function(){YA.setClearColor.apply(YA,arguments)},this.getClearAlpha=function(){return YA.getClearAlpha()},this.setClearAlpha=function(){YA.setClearAlpha.apply(YA,arguments)},this.clear=function(Qe=!0,Le=!0,$e=!0){let ze=0;if(Qe){let Je=!1;if(x!==null){const qt=x.texture.format;Je=qt===xDA||qt===bDA||qt===SDA}if(Je){const qt=x.texture.type,Ut=qt===Qb||qt===p_||qt===$J||qt===f_||qt===mDA||qt===wDA,ti=YA.getClearColor(),ri=YA.getClearAlpha(),Ht=ti.r,so=ti.g,Yi=ti.b;Ut?(C[0]=Ht,C[1]=so,C[2]=Yi,C[3]=ri,uA.clearBufferuiv(uA.COLOR,0,C)):(l[0]=Ht,l[1]=so,l[2]=Yi,l[3]=ri,uA.clearBufferiv(uA.COLOR,0,l))}else ze|=uA.COLOR_BUFFER_BIT}Le&&(ze|=uA.DEPTH_BUFFER_BIT),$e&&(ze|=uA.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),uA.clear(ze)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",ae,!1),e.removeEventListener("webglcontextrestored",Ce,!1),e.removeEventListener("webglcontextcreationerror",me,!1),oe.dispose(),DA.dispose(),KA.dispose(),jA.dispose(),GA.dispose(),FA.dispose(),Xe.dispose(),Ve.dispose(),TA.dispose(),EA.dispose(),EA.removeEventListener("sessionstart",Ft),EA.removeEventListener("sessionend",Mt),Tt.stop()};function ae(Qe){Qe.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),f=!0}function Ce(){console.log("THREE.WebGLRenderer: Context Restored."),f=!1;const Qe=WA.autoReset,Le=QA.enabled,$e=QA.autoUpdate,ze=QA.needsUpdate,Je=QA.type;lt(),WA.autoReset=Qe,QA.enabled=Le,QA.autoUpdate=$e,QA.needsUpdate=ze,QA.type=Je}function me(Qe){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Qe.statusMessage)}function Ue(Qe){const Le=Qe.target;Le.removeEventListener("dispose",Ue),Ye(Le)}function Ye(Qe){gt(Qe),KA.remove(Qe)}function gt(Qe){const Le=KA.get(Qe).programs;Le!==void 0&&(Le.forEach(function($e){TA.releaseProgram($e)}),Qe.isShaderMaterial&&TA.releaseShaderCache(Qe))}this.renderBufferDirect=function(Qe,Le,$e,ze,Je,qt){Le===null&&(Le=qA);const Ut=Je.isMesh&&Je.matrixWorld.determinant()<0,ti=At(Qe,Le,$e,ze,Je);yA.setMaterial(ze,Ut);let ri=$e.index,Ht=1;if(ze.wireframe===!0){if(ri=_A.getWireframeAttribute($e),ri===void 0)return;Ht=2}const so=$e.drawRange,Yi=$e.attributes.position;let ao=so.start*Ht,an=(so.start+so.count)*Ht;qt!==null&&(ao=Math.max(ao,qt.start*Ht),an=Math.min(an,(qt.start+qt.count)*Ht)),ri!==null?(ao=Math.max(ao,0),an=Math.min(an,ri.count)):Yi!=null&&(ao=Math.max(ao,0),an=Math.min(an,Yi.count));const pn=an-ao;if(pn<0||pn===1/0)return;Xe.setup(Je,ze,ti,$e,ri);let jn,qi=he;if(ri!==null&&(jn=SA.get(ri),qi=De,qi.setIndex(jn)),Je.isMesh)ze.wireframe===!0?(yA.setLineWidth(ze.wireframeLinewidth*mA()),qi.setMode(uA.LINES)):qi.setMode(uA.TRIANGLES);else if(Je.isLine){let fi=ze.linewidth;fi===void 0&&(fi=1),yA.setLineWidth(fi*mA()),Je.isLineSegments?qi.setMode(uA.LINES):Je.isLineLoop?qi.setMode(uA.LINE_LOOP):qi.setMode(uA.LINE_STRIP)}else Je.isPoints?qi.setMode(uA.POINTS):Je.isSprite&&qi.setMode(uA.TRIANGLES);if(Je.isBatchedMesh)Je._multiDrawInstances!==null?qi.renderMultiDrawInstances(Je._multiDrawStarts,Je._multiDrawCounts,Je._multiDrawCount,Je._multiDrawInstances):qi.renderMultiDraw(Je._multiDrawStarts,Je._multiDrawCounts,Je._multiDrawCount);else if(Je.isInstancedMesh)qi.renderInstances(ao,pn,Je.count);else if($e.isInstancedBufferGeometry){const fi=$e._maxInstanceCount!==void 0?$e._maxInstanceCount:1/0,zo=Math.min($e.instanceCount,fi);qi.renderInstances(ao,pn,zo)}else qi.render(ao,pn)};function Jt(Qe,Le,$e){Qe.transparent===!0&&Qe.side===JC&&Qe.forceSinglePass===!1?(Qe.side=rh,Qe.needsUpdate=!0,Lt(Qe,Le,$e),Qe.side=Oy,Qe.needsUpdate=!0,Lt(Qe,Le,$e),Qe.side=JC):Lt(Qe,Le,$e)}this.compile=function(Qe,Le,$e=null){$e===null&&($e=Qe),E=DA.get($e),E.init(Le),u.push(E),$e.traverseVisible(function(Je){Je.isLight&&Je.layers.test(Le.layers)&&(E.pushLight(Je),Je.castShadow&&E.pushShadow(Je))}),Qe!==$e&&Qe.traverseVisible(function(Je){Je.isLight&&Je.layers.test(Le.layers)&&(E.pushLight(Je),Je.castShadow&&E.pushShadow(Je))}),E.setupLights();const ze=new Set;return Qe.traverse(function(Je){const qt=Je.material;if(qt)if(Array.isArray(qt))for(let Ut=0;Ut<qt.length;Ut++){const ti=qt[Ut];Jt(ti,$e,Je),ze.add(ti)}else Jt(qt,$e,Je),ze.add(qt)}),u.pop(),E=null,ze},this.compileAsync=function(Qe,Le,$e=null){const ze=this.compile(Qe,Le,$e);return new Promise(Je=>{function qt(){if(ze.forEach(function(Ut){KA.get(Ut).currentProgram.isReady()&&ze.delete(Ut)}),ze.size===0){Je(Qe);return}setTimeout(qt,10)}ee.get("KHR_parallel_shader_compile")!==null?qt():setTimeout(qt,10)})};let St=null;function ot(Qe){St&&St(Qe)}function Ft(){Tt.stop()}function Mt(){Tt.start()}const Tt=new LSA;Tt.setAnimationLoop(ot),typeof self<"u"&&Tt.setContext(self),this.setAnimationLoop=function(Qe){St=Qe,EA.setAnimationLoop(Qe),Qe===null?Tt.stop():Tt.start()},EA.addEventListener("sessionstart",Ft),EA.addEventListener("sessionend",Mt),this.render=function(Qe,Le){if(Le!==void 0&&Le.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(f===!0)return;if(Qe.matrixWorldAutoUpdate===!0&&Qe.updateMatrixWorld(),Le.parent===null&&Le.matrixWorldAutoUpdate===!0&&Le.updateMatrixWorld(),EA.enabled===!0&&EA.isPresenting===!0&&(EA.cameraAutoUpdate===!0&&EA.updateCamera(Le),Le=EA.getCamera()),Qe.isScene===!0&&Qe.onBeforeRender(d,Qe,Le,x),E=DA.get(Qe,u.length),E.init(Le),u.push(E),vA.multiplyMatrices(Le.projectionMatrix,Le.matrixWorldInverse),gA.setFromProjectionMatrix(vA),bA=this.localClippingEnabled,pA=BA.init(this.clippingPlanes,bA),Q=oe.get(Qe,h.length),Q.init(),h.push(Q),EA.enabled===!0&&EA.isPresenting===!0){const qt=d.xr.getDepthSensingMesh();qt!==null&&vt(qt,Le,-1/0,d.sortObjects)}vt(Qe,Le,0,d.sortObjects),Q.finish(),d.sortObjects===!0&&Q.sort($,oA),CA=EA.enabled===!1||EA.isPresenting===!1||EA.hasDepthSensing()===!1,CA&&YA.addToRenderList(Q,Qe),this.info.render.frame++,pA===!0&&BA.beginShadows();const $e=E.state.shadowsArray;QA.render($e,Qe,Le),pA===!0&&BA.endShadows(),this.info.autoReset===!0&&this.info.reset();const ze=Q.opaque,Je=Q.transmissive;if(E.setupLights(),Le.isArrayCamera){const qt=Le.cameras;if(Je.length>0)for(let Ut=0,ti=qt.length;Ut<ti;Ut++){const ri=qt[Ut];ue(ze,Je,Qe,ri)}CA&&YA.render(Qe);for(let Ut=0,ti=qt.length;Ut<ti;Ut++){const ri=qt[Ut];Nt(Q,Qe,ri,ri.viewport)}}else Je.length>0&&ue(ze,Je,Qe,Le),CA&&YA.render(Qe),Nt(Q,Qe,Le);x!==null&&(JA.updateMultisampleRenderTarget(x),JA.updateRenderTargetMipmap(x)),Qe.isScene===!0&&Qe.onAfterRender(d,Qe,Le),Xe.resetDefaultState(),b=-1,F=null,u.pop(),u.length>0?(E=u[u.length-1],pA===!0&&BA.setGlobalState(d.clippingPlanes,E.state.camera)):E=null,h.pop(),h.length>0?Q=h[h.length-1]:Q=null};function vt(Qe,Le,$e,ze){if(Qe.visible===!1)return;if(Qe.layers.test(Le.layers)){if(Qe.isGroup)$e=Qe.renderOrder;else if(Qe.isLOD)Qe.autoUpdate===!0&&Qe.update(Le);else if(Qe.isLight)E.pushLight(Qe),Qe.castShadow&&E.pushShadow(Qe);else if(Qe.isSprite){if(!Qe.frustumCulled||gA.intersectsSprite(Qe)){ze&&MA.setFromMatrixPosition(Qe.matrixWorld).applyMatrix4(vA);const Ut=FA.update(Qe),ti=Qe.material;ti.visible&&Q.push(Qe,Ut,ti,$e,MA.z,null)}}else if((Qe.isMesh||Qe.isLine||Qe.isPoints)&&(!Qe.frustumCulled||gA.intersectsObject(Qe))){const Ut=FA.update(Qe),ti=Qe.material;if(ze&&(Qe.boundingSphere!==void 0?(Qe.boundingSphere===null&&Qe.computeBoundingSphere(),MA.copy(Qe.boundingSphere.center)):(Ut.boundingSphere===null&&Ut.computeBoundingSphere(),MA.copy(Ut.boundingSphere.center)),MA.applyMatrix4(Qe.matrixWorld).applyMatrix4(vA)),Array.isArray(ti)){const ri=Ut.groups;for(let Ht=0,so=ri.length;Ht<so;Ht++){const Yi=ri[Ht],ao=ti[Yi.materialIndex];ao&&ao.visible&&Q.push(Qe,Ut,ao,$e,MA.z,Yi)}}else ti.visible&&Q.push(Qe,Ut,ti,$e,MA.z,null)}}const qt=Qe.children;for(let Ut=0,ti=qt.length;Ut<ti;Ut++)vt(qt[Ut],Le,$e,ze)}function Nt(Qe,Le,$e,ze){const Je=Qe.opaque,qt=Qe.transmissive,Ut=Qe.transparent;E.setupLightsView($e),pA===!0&&BA.setGlobalState(d.clippingPlanes,$e),ze&&yA.viewport(k.copy(ze)),Je.length>0&&Te(Je,Le,$e),qt.length>0&&Te(qt,Le,$e),Ut.length>0&&Te(Ut,Le,$e),yA.buffers.depth.setTest(!0),yA.buffers.depth.setMask(!0),yA.buffers.color.setMask(!0),yA.setPolygonOffset(!1)}function ue(Qe,Le,$e,ze){if(($e.isScene===!0?$e.overrideMaterial:null)!==null)return;E.state.transmissionRenderTarget[ze.id]===void 0&&(E.state.transmissionRenderTarget[ze.id]=new vk(1,1,{generateMipmaps:!0,type:ee.has("EXT_color_buffer_half_float")||ee.has("EXT_color_buffer_float")?AK:Qb,minFilter:Ed,samples:4,stencilBuffer:n,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:hg.workingColorSpace}));const qt=E.state.transmissionRenderTarget[ze.id],Ut=ze.viewport||k;qt.setSize(Ut.z,Ut.w);const ti=d.getRenderTarget();d.setRenderTarget(qt),d.getClearColor(J),P=d.getClearAlpha(),P<1&&d.setClearColor(16777215,.5),CA?YA.render($e):d.clear();const ri=d.toneMapping;d.toneMapping=lb;const Ht=ze.viewport;if(ze.viewport!==void 0&&(ze.viewport=void 0),E.setupLightsView(ze),pA===!0&&BA.setGlobalState(d.clippingPlanes,ze),Te(Qe,$e,ze),JA.updateMultisampleRenderTarget(qt),JA.updateRenderTargetMipmap(qt),ee.has("WEBGL_multisampled_render_to_texture")===!1){let so=!1;for(let Yi=0,ao=Le.length;Yi<ao;Yi++){const an=Le[Yi],pn=an.object,jn=an.geometry,qi=an.material,fi=an.group;if(qi.side===JC&&pn.layers.test(ze.layers)){const zo=qi.side;qi.side=rh,qi.needsUpdate=!0,dt(pn,$e,ze,jn,qi,fi),qi.side=zo,qi.needsUpdate=!0,so=!0}}so===!0&&(JA.updateMultisampleRenderTarget(qt),JA.updateRenderTargetMipmap(qt))}d.setRenderTarget(ti),d.setClearColor(J,P),Ht!==void 0&&(ze.viewport=Ht),d.toneMapping=ri}function Te(Qe,Le,$e){const ze=Le.isScene===!0?Le.overrideMaterial:null;for(let Je=0,qt=Qe.length;Je<qt;Je++){const Ut=Qe[Je],ti=Ut.object,ri=Ut.geometry,Ht=ze===null?Ut.material:ze,so=Ut.group;ti.layers.test($e.layers)&&dt(ti,Le,$e,ri,Ht,so)}}function dt(Qe,Le,$e,ze,Je,qt){Qe.onBeforeRender(d,Le,$e,ze,Je,qt),Qe.modelViewMatrix.multiplyMatrices($e.matrixWorldInverse,Qe.matrixWorld),Qe.normalMatrix.getNormalMatrix(Qe.modelViewMatrix),Je.onBeforeRender(d,Le,$e,ze,Qe,qt),Je.transparent===!0&&Je.side===JC&&Je.forceSinglePass===!1?(Je.side=rh,Je.needsUpdate=!0,d.renderBufferDirect($e,Le,ze,Je,Qe,qt),Je.side=Oy,Je.needsUpdate=!0,d.renderBufferDirect($e,Le,ze,Je,Qe,qt),Je.side=JC):d.renderBufferDirect($e,Le,ze,Je,Qe,qt),Qe.onAfterRender(d,Le,$e,ze,Je,qt)}function Lt(Qe,Le,$e){Le.isScene!==!0&&(Le=qA);const ze=KA.get(Qe),Je=E.state.lights,qt=E.state.shadowsArray,Ut=Je.state.version,ti=TA.getParameters(Qe,Je.state,qt,Le,$e),ri=TA.getProgramCacheKey(ti);let Ht=ze.programs;ze.environment=Qe.isMeshStandardMaterial?Le.environment:null,ze.fog=Le.fog,ze.envMap=(Qe.isMeshStandardMaterial?GA:jA).get(Qe.envMap||ze.environment),ze.envMapRotation=ze.environment!==null&&Qe.envMap===null?Le.environmentRotation:Qe.envMapRotation,Ht===void 0&&(Qe.addEventListener("dispose",Ue),Ht=new Map,ze.programs=Ht);let so=Ht.get(ri);if(so!==void 0){if(ze.currentProgram===so&&ze.lightsStateVersion===Ut)return si(Qe,ti),so}else ti.uniforms=TA.getUniforms(Qe),Qe.onBuild($e,ti,d),Qe.onBeforeCompile(ti,d),so=TA.acquireProgram(ti,ri),Ht.set(ri,so),ze.uniforms=ti.uniforms;const Yi=ze.uniforms;return(!Qe.isShaderMaterial&&!Qe.isRawShaderMaterial||Qe.clipping===!0)&&(Yi.clippingPlanes=BA.uniform),si(Qe,ti),ze.needsLights=ji(Qe),ze.lightsStateVersion=Ut,ze.needsLights&&(Yi.ambientLightColor.value=Je.state.ambient,Yi.lightProbe.value=Je.state.probe,Yi.directionalLights.value=Je.state.directional,Yi.directionalLightShadows.value=Je.state.directionalShadow,Yi.spotLights.value=Je.state.spot,Yi.spotLightShadows.value=Je.state.spotShadow,Yi.rectAreaLights.value=Je.state.rectArea,Yi.ltc_1.value=Je.state.rectAreaLTC1,Yi.ltc_2.value=Je.state.rectAreaLTC2,Yi.pointLights.value=Je.state.point,Yi.pointLightShadows.value=Je.state.pointShadow,Yi.hemisphereLights.value=Je.state.hemi,Yi.directionalShadowMap.value=Je.state.directionalShadowMap,Yi.directionalShadowMatrix.value=Je.state.directionalShadowMatrix,Yi.spotShadowMap.value=Je.state.spotShadowMap,Yi.spotLightMatrix.value=Je.state.spotLightMatrix,Yi.spotLightMap.value=Je.state.spotLightMap,Yi.pointShadowMap.value=Je.state.pointShadowMap,Yi.pointShadowMatrix.value=Je.state.pointShadowMatrix),ze.currentProgram=so,ze.uniformsList=null,so}function Ni(Qe){if(Qe.uniformsList===null){const Le=Qe.currentProgram.getUniforms();Qe.uniformsList=xK.seqWithValue(Le.seq,Qe.uniforms)}return Qe.uniformsList}function si(Qe,Le){const $e=KA.get(Qe);$e.outputColorSpace=Le.outputColorSpace,$e.batching=Le.batching,$e.batchingColor=Le.batchingColor,$e.instancing=Le.instancing,$e.instancingColor=Le.instancingColor,$e.instancingMorph=Le.instancingMorph,$e.skinning=Le.skinning,$e.morphTargets=Le.morphTargets,$e.morphNormals=Le.morphNormals,$e.morphColors=Le.morphColors,$e.morphTargetsCount=Le.morphTargetsCount,$e.numClippingPlanes=Le.numClippingPlanes,$e.numIntersection=Le.numClipIntersection,$e.vertexAlphas=Le.vertexAlphas,$e.vertexTangents=Le.vertexTangents,$e.toneMapping=Le.toneMapping}function At(Qe,Le,$e,ze,Je){Le.isScene!==!0&&(Le=qA),JA.resetTextureUnits();const qt=Le.fog,Ut=ze.isMeshStandardMaterial?Le.environment:null,ti=x===null?d.outputColorSpace:x.isXRRenderTarget===!0?x.texture.colorSpace:hb,ri=(ze.isMeshStandardMaterial?GA:jA).get(ze.envMap||Ut),Ht=ze.vertexColors===!0&&!!$e.attributes.color&&$e.attributes.color.itemSize===4,so=!!$e.attributes.tangent&&(!!ze.normalMap||ze.anisotropy>0),Yi=!!$e.morphAttributes.position,ao=!!$e.morphAttributes.normal,an=!!$e.morphAttributes.color;let pn=lb;ze.toneMapped&&(x===null||x.isXRRenderTarget===!0)&&(pn=d.toneMapping);const jn=$e.morphAttributes.position||$e.morphAttributes.normal||$e.morphAttributes.color,qi=jn!==void 0?jn.length:0,fi=KA.get(ze),zo=E.state.lights;if(pA===!0&&(bA===!0||Qe!==F)){const qs=Qe===F&&ze.id===b;BA.setState(ze,Qe,qs)}let yi=!1;ze.version===fi.__version?(fi.needsLights&&fi.lightsStateVersion!==zo.state.version||fi.outputColorSpace!==ti||Je.isBatchedMesh&&fi.batching===!1||!Je.isBatchedMesh&&fi.batching===!0||Je.isBatchedMesh&&fi.batchingColor===!0&&Je.colorTexture===null||Je.isBatchedMesh&&fi.batchingColor===!1&&Je.colorTexture!==null||Je.isInstancedMesh&&fi.instancing===!1||!Je.isInstancedMesh&&fi.instancing===!0||Je.isSkinnedMesh&&fi.skinning===!1||!Je.isSkinnedMesh&&fi.skinning===!0||Je.isInstancedMesh&&fi.instancingColor===!0&&Je.instanceColor===null||Je.isInstancedMesh&&fi.instancingColor===!1&&Je.instanceColor!==null||Je.isInstancedMesh&&fi.instancingMorph===!0&&Je.morphTexture===null||Je.isInstancedMesh&&fi.instancingMorph===!1&&Je.morphTexture!==null||fi.envMap!==ri||ze.fog===!0&&fi.fog!==qt||fi.numClippingPlanes!==void 0&&(fi.numClippingPlanes!==BA.numPlanes||fi.numIntersection!==BA.numIntersection)||fi.vertexAlphas!==Ht||fi.vertexTangents!==so||fi.morphTargets!==Yi||fi.morphNormals!==ao||fi.morphColors!==an||fi.toneMapping!==pn||fi.morphTargetsCount!==qi)&&(yi=!0):(yi=!0,fi.__version=ze.version);let Qa=fi.currentProgram;yi===!0&&(Qa=Lt(ze,Le,Je));let ig=!1,Ms=!1,Ka=!1;const vs=Qa.getUniforms(),Us=fi.uniforms;if(yA.useProgram(Qa.program)&&(ig=!0,Ms=!0,Ka=!0),ze.id!==b&&(b=ze.id,Ms=!0),ig||F!==Qe){vs.setValue(uA,"projectionMatrix",Qe.projectionMatrix),vs.setValue(uA,"viewMatrix",Qe.matrixWorldInverse);const qs=vs.map.cameraPosition;qs!==void 0&&qs.setValue(uA,MA.setFromMatrixPosition(Qe.matrixWorld)),Be.logarithmicDepthBuffer&&vs.setValue(uA,"logDepthBufFC",2/(Math.log(Qe.far+1)/Math.LN2)),(ze.isMeshPhongMaterial||ze.isMeshToonMaterial||ze.isMeshLambertMaterial||ze.isMeshBasicMaterial||ze.isMeshStandardMaterial||ze.isShaderMaterial)&&vs.setValue(uA,"isOrthographic",Qe.isOrthographicCamera===!0),F!==Qe&&(F=Qe,Ms=!0,Ka=!0)}if(Je.isSkinnedMesh){vs.setOptional(uA,Je,"bindMatrix"),vs.setOptional(uA,Je,"bindMatrixInverse");const qs=Je.skeleton;qs&&(qs.boneTexture===null&&qs.computeBoneTexture(),vs.setValue(uA,"boneTexture",qs.boneTexture,JA))}Je.isBatchedMesh&&(vs.setOptional(uA,Je,"batchingTexture"),vs.setValue(uA,"batchingTexture",Je._matricesTexture,JA),vs.setOptional(uA,Je,"batchingColorTexture"),Je._colorsTexture!==null&&vs.setValue(uA,"batchingColorTexture",Je._colorsTexture,JA));const hI=$e.morphAttributes;if((hI.position!==void 0||hI.normal!==void 0||hI.color!==void 0)&&se.update(Je,$e,Qa),(Ms||fi.receiveShadow!==Je.receiveShadow)&&(fi.receiveShadow=Je.receiveShadow,vs.setValue(uA,"receiveShadow",Je.receiveShadow)),ze.isMeshGouraudMaterial&&ze.envMap!==null&&(Us.envMap.value=ri,Us.flipEnvMap.value=ri.isCubeTexture&&ri.isRenderTargetTexture===!1?-1:1),ze.isMeshStandardMaterial&&ze.envMap===null&&Le.environment!==null&&(Us.envMapIntensity.value=Le.environmentIntensity),Ms&&(vs.setValue(uA,"toneMappingExposure",d.toneMappingExposure),fi.needsLights&&rn(Us,Ka),qt&&ze.fog===!0&&OA.refreshFogUniforms(Us,qt),OA.refreshMaterialUniforms(Us,ze,W,O,E.state.transmissionRenderTarget[Qe.id]),xK.upload(uA,Ni(fi),Us,JA)),ze.isShaderMaterial&&ze.uniformsNeedUpdate===!0&&(xK.upload(uA,Ni(fi),Us,JA),ze.uniformsNeedUpdate=!1),ze.isSpriteMaterial&&vs.setValue(uA,"center",Je.center),vs.setValue(uA,"modelViewMatrix",Je.modelViewMatrix),vs.setValue(uA,"normalMatrix",Je.normalMatrix),vs.setValue(uA,"modelMatrix",Je.matrixWorld),ze.isShaderMaterial||ze.isRawShaderMaterial){const qs=ze.uniformsGroups;for(let Fl=0,kr=qs.length;Fl<kr;Fl++){const DQ=qs[Fl];Ve.update(DQ,Qa),Ve.bind(DQ,Qa)}}return Qa}function rn(Qe,Le){Qe.ambientLightColor.needsUpdate=Le,Qe.lightProbe.needsUpdate=Le,Qe.directionalLights.needsUpdate=Le,Qe.directionalLightShadows.needsUpdate=Le,Qe.pointLights.needsUpdate=Le,Qe.pointLightShadows.needsUpdate=Le,Qe.spotLights.needsUpdate=Le,Qe.spotLightShadows.needsUpdate=Le,Qe.rectAreaLights.needsUpdate=Le,Qe.hemisphereLights.needsUpdate=Le}function ji(Qe){return Qe.isMeshLambertMaterial||Qe.isMeshToonMaterial||Qe.isMeshPhongMaterial||Qe.isMeshStandardMaterial||Qe.isShadowMaterial||Qe.isShaderMaterial&&Qe.lights===!0}this.getActiveCubeFace=function(){return D},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(Qe,Le,$e){KA.get(Qe.texture).__webglTexture=Le,KA.get(Qe.depthTexture).__webglTexture=$e;const ze=KA.get(Qe);ze.__hasExternalTextures=!0,ze.__autoAllocateDepthBuffer=$e===void 0,ze.__autoAllocateDepthBuffer||ee.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ze.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(Qe,Le){const $e=KA.get(Qe);$e.__webglFramebuffer=Le,$e.__useDefaultFramebuffer=Le===void 0},this.setRenderTarget=function(Qe,Le=0,$e=0){x=Qe,D=Le,w=$e;let ze=!0,Je=null,qt=!1,Ut=!1;if(Qe){const ri=KA.get(Qe);ri.__useDefaultFramebuffer!==void 0?(yA.bindFramebuffer(uA.FRAMEBUFFER,null),ze=!1):ri.__webglFramebuffer===void 0?JA.setupRenderTarget(Qe):ri.__hasExternalTextures&&JA.rebindTextures(Qe,KA.get(Qe.texture).__webglTexture,KA.get(Qe.depthTexture).__webglTexture);const Ht=Qe.texture;(Ht.isData3DTexture||Ht.isDataArrayTexture||Ht.isCompressedArrayTexture)&&(Ut=!0);const so=KA.get(Qe).__webglFramebuffer;Qe.isWebGLCubeRenderTarget?(Array.isArray(so[Le])?Je=so[Le][$e]:Je=so[Le],qt=!0):Qe.samples>0&&JA.useMultisampledRTT(Qe)===!1?Je=KA.get(Qe).__webglMultisampledFramebuffer:Array.isArray(so)?Je=so[$e]:Je=so,k.copy(Qe.viewport),U.copy(Qe.scissor),N=Qe.scissorTest}else k.copy(IA).multiplyScalar(W).floor(),U.copy(tA).multiplyScalar(W).floor(),N=sA;if(yA.bindFramebuffer(uA.FRAMEBUFFER,Je)&&ze&&yA.drawBuffers(Qe,Je),yA.viewport(k),yA.scissor(U),yA.setScissorTest(N),qt){const ri=KA.get(Qe.texture);uA.framebufferTexture2D(uA.FRAMEBUFFER,uA.COLOR_ATTACHMENT0,uA.TEXTURE_CUBE_MAP_POSITIVE_X+Le,ri.__webglTexture,$e)}else if(Ut){const ri=KA.get(Qe.texture),Ht=Le||0;uA.framebufferTextureLayer(uA.FRAMEBUFFER,uA.COLOR_ATTACHMENT0,ri.__webglTexture,$e||0,Ht)}b=-1},this.readRenderTargetPixels=function(Qe,Le,$e,ze,Je,qt,Ut){if(!(Qe&&Qe.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ti=KA.get(Qe).__webglFramebuffer;if(Qe.isWebGLCubeRenderTarget&&Ut!==void 0&&(ti=ti[Ut]),ti){yA.bindFramebuffer(uA.FRAMEBUFFER,ti);try{const ri=Qe.texture,Ht=ri.format,so=ri.type;if(!Be.textureFormatReadable(Ht)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Be.textureTypeReadable(so)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Le>=0&&Le<=Qe.width-ze&&$e>=0&&$e<=Qe.height-Je&&uA.readPixels(Le,$e,ze,Je,Fe.convert(Ht),Fe.convert(so),qt)}finally{const ri=x!==null?KA.get(x).__webglFramebuffer:null;yA.bindFramebuffer(uA.FRAMEBUFFER,ri)}}},this.readRenderTargetPixelsAsync=async function(Qe,Le,$e,ze,Je,qt,Ut){if(!(Qe&&Qe.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ti=KA.get(Qe).__webglFramebuffer;if(Qe.isWebGLCubeRenderTarget&&Ut!==void 0&&(ti=ti[Ut]),ti){yA.bindFramebuffer(uA.FRAMEBUFFER,ti);try{const ri=Qe.texture,Ht=ri.format,so=ri.type;if(!Be.textureFormatReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Be.textureTypeReadable(so))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(Le>=0&&Le<=Qe.width-ze&&$e>=0&&$e<=Qe.height-Je){const Yi=uA.createBuffer();uA.bindBuffer(uA.PIXEL_PACK_BUFFER,Yi),uA.bufferData(uA.PIXEL_PACK_BUFFER,qt.byteLength,uA.STREAM_READ),uA.readPixels(Le,$e,ze,Je,Fe.convert(Ht),Fe.convert(so),0),uA.flush();const ao=uA.fenceSync(uA.SYNC_GPU_COMMANDS_COMPLETE,0);await h0e(uA,ao,4);try{uA.bindBuffer(uA.PIXEL_PACK_BUFFER,Yi),uA.getBufferSubData(uA.PIXEL_PACK_BUFFER,0,qt)}finally{uA.deleteBuffer(Yi),uA.deleteSync(ao)}return qt}}finally{const ri=x!==null?KA.get(x).__webglFramebuffer:null;yA.bindFramebuffer(uA.FRAMEBUFFER,ri)}}},this.copyFramebufferToTexture=function(Qe,Le=null,$e=0){Qe.isTexture!==!0&&(console.warn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),Le=arguments[0]||null,Qe=arguments[1]);const ze=Math.pow(2,-$e),Je=Math.floor(Qe.image.width*ze),qt=Math.floor(Qe.image.height*ze),Ut=Le!==null?Le.x:0,ti=Le!==null?Le.y:0;JA.setTexture2D(Qe,0),uA.copyTexSubImage2D(uA.TEXTURE_2D,$e,0,0,Ut,ti,Je,qt),yA.unbindTexture()},this.copyTextureToTexture=function(Qe,Le,$e=null,ze=null,Je=0){Qe.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture function signature has changed."),ze=arguments[0]||null,Qe=arguments[1],Le=arguments[2],Je=arguments[3]||0,$e=null);let qt,Ut,ti,ri,Ht,so;$e!==null?(qt=$e.max.x-$e.min.x,Ut=$e.max.y-$e.min.y,ti=$e.min.x,ri=$e.min.y):(qt=Qe.image.width,Ut=Qe.image.height,ti=0,ri=0),ze!==null?(Ht=ze.x,so=ze.y):(Ht=0,so=0);const Yi=Fe.convert(Le.format),ao=Fe.convert(Le.type);JA.setTexture2D(Le,0),uA.pixelStorei(uA.UNPACK_FLIP_Y_WEBGL,Le.flipY),uA.pixelStorei(uA.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Le.premultiplyAlpha),uA.pixelStorei(uA.UNPACK_ALIGNMENT,Le.unpackAlignment);const an=uA.getParameter(uA.UNPACK_ROW_LENGTH),pn=uA.getParameter(uA.UNPACK_IMAGE_HEIGHT),jn=uA.getParameter(uA.UNPACK_SKIP_PIXELS),qi=uA.getParameter(uA.UNPACK_SKIP_ROWS),fi=uA.getParameter(uA.UNPACK_SKIP_IMAGES),zo=Qe.isCompressedTexture?Qe.mipmaps[Je]:Qe.image;uA.pixelStorei(uA.UNPACK_ROW_LENGTH,zo.width),uA.pixelStorei(uA.UNPACK_IMAGE_HEIGHT,zo.height),uA.pixelStorei(uA.UNPACK_SKIP_PIXELS,ti),uA.pixelStorei(uA.UNPACK_SKIP_ROWS,ri),Qe.isDataTexture?uA.texSubImage2D(uA.TEXTURE_2D,Je,Ht,so,qt,Ut,Yi,ao,zo.data):Qe.isCompressedTexture?uA.compressedTexSubImage2D(uA.TEXTURE_2D,Je,Ht,so,zo.width,zo.height,Yi,zo.data):uA.texSubImage2D(uA.TEXTURE_2D,Je,Ht,so,Yi,ao,zo),uA.pixelStorei(uA.UNPACK_ROW_LENGTH,an),uA.pixelStorei(uA.UNPACK_IMAGE_HEIGHT,pn),uA.pixelStorei(uA.UNPACK_SKIP_PIXELS,jn),uA.pixelStorei(uA.UNPACK_SKIP_ROWS,qi),uA.pixelStorei(uA.UNPACK_SKIP_IMAGES,fi),Je===0&&Le.generateMipmaps&&uA.generateMipmap(uA.TEXTURE_2D),yA.unbindTexture()},this.copyTextureToTexture3D=function(Qe,Le,$e=null,ze=null,Je=0){Qe.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),$e=arguments[0]||null,ze=arguments[1]||null,Qe=arguments[2],Le=arguments[3],Je=arguments[4]||0);let qt,Ut,ti,ri,Ht,so,Yi,ao,an;const pn=Qe.isCompressedTexture?Qe.mipmaps[Je]:Qe.image;$e!==null?(qt=$e.max.x-$e.min.x,Ut=$e.max.y-$e.min.y,ti=$e.max.z-$e.min.z,ri=$e.min.x,Ht=$e.min.y,so=$e.min.z):(qt=pn.width,Ut=pn.height,ti=pn.depth,ri=0,Ht=0,so=0),ze!==null?(Yi=ze.x,ao=ze.y,an=ze.z):(Yi=0,ao=0,an=0);const jn=Fe.convert(Le.format),qi=Fe.convert(Le.type);let fi;if(Le.isData3DTexture)JA.setTexture3D(Le,0),fi=uA.TEXTURE_3D;else if(Le.isDataArrayTexture||Le.isCompressedArrayTexture)JA.setTexture2DArray(Le,0),fi=uA.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}uA.pixelStorei(uA.UNPACK_FLIP_Y_WEBGL,Le.flipY),uA.pixelStorei(uA.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Le.premultiplyAlpha),uA.pixelStorei(uA.UNPACK_ALIGNMENT,Le.unpackAlignment);const zo=uA.getParameter(uA.UNPACK_ROW_LENGTH),yi=uA.getParameter(uA.UNPACK_IMAGE_HEIGHT),Qa=uA.getParameter(uA.UNPACK_SKIP_PIXELS),ig=uA.getParameter(uA.UNPACK_SKIP_ROWS),Ms=uA.getParameter(uA.UNPACK_SKIP_IMAGES);uA.pixelStorei(uA.UNPACK_ROW_LENGTH,pn.width),uA.pixelStorei(uA.UNPACK_IMAGE_HEIGHT,pn.height),uA.pixelStorei(uA.UNPACK_SKIP_PIXELS,ri),uA.pixelStorei(uA.UNPACK_SKIP_ROWS,Ht),uA.pixelStorei(uA.UNPACK_SKIP_IMAGES,so),Qe.isDataTexture||Qe.isData3DTexture?uA.texSubImage3D(fi,Je,Yi,ao,an,qt,Ut,ti,jn,qi,pn.data):Le.isCompressedArrayTexture?uA.compressedTexSubImage3D(fi,Je,Yi,ao,an,qt,Ut,ti,jn,pn.data):uA.texSubImage3D(fi,Je,Yi,ao,an,qt,Ut,ti,jn,qi,pn),uA.pixelStorei(uA.UNPACK_ROW_LENGTH,zo),uA.pixelStorei(uA.UNPACK_IMAGE_HEIGHT,yi),uA.pixelStorei(uA.UNPACK_SKIP_PIXELS,Qa),uA.pixelStorei(uA.UNPACK_SKIP_ROWS,ig),uA.pixelStorei(uA.UNPACK_SKIP_IMAGES,Ms),Je===0&&Le.generateMipmaps&&uA.generateMipmap(fi),yA.unbindTexture()},this.initRenderTarget=function(Qe){KA.get(Qe).__webglFramebuffer===void 0&&JA.setupRenderTarget(Qe)},this.initTexture=function(Qe){Qe.isCubeTexture?JA.setTextureCube(Qe,0):Qe.isData3DTexture?JA.setTexture3D(Qe,0):Qe.isDataArrayTexture||Qe.isCompressedArrayTexture?JA.setTexture2DArray(Qe,0):JA.setTexture2D(Qe,0),yA.unbindTexture()},this.resetState=function(){D=0,w=0,x=null,yA.reset(),Xe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return xD}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(A){this._outputColorSpace=A;const e=this.getContext();e.drawingBufferColorSpace=A===yj?"display-p3":"srgb",e.unpackColorSpace=hg.workingColorSpace===eK?"display-p3":"srgb"}}class Pk extends dg{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Np,this.environmentIntensity=1,this.environmentRotation=new Np,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(A,e){return super.copy(A,e),A.background!==null&&(this.background=A.background.clone()),A.environment!==null&&(this.environment=A.environment.clone()),A.fog!==null&&(this.fog=A.fog.clone()),this.backgroundBlurriness=A.backgroundBlurriness,this.backgroundIntensity=A.backgroundIntensity,this.backgroundRotation.copy(A.backgroundRotation),this.environmentIntensity=A.environmentIntensity,this.environmentRotation.copy(A.environmentRotation),A.overrideMaterial!==null&&(this.overrideMaterial=A.overrideMaterial.clone()),this.matrixAutoUpdate=A.matrixAutoUpdate,this}toJSON(A){const e=super.toJSON(A);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class JDe{constructor(A,e){this.isInterleavedBuffer=!0,this.array=A,this.stride=e,this.count=A!==void 0?A.length/e:0,this.usage=mj,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Zy()}onUploadCallback(){}set needsUpdate(A){A===!0&&this.version++}get updateRange(){return Sj("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(A){return this.usage=A,this}addUpdateRange(A,e){this.updateRanges.push({start:A,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(A){return this.array=new A.array.constructor(A.array),this.count=A.count,this.stride=A.stride,this.usage=A.usage,this}copyAt(A,e,i){A*=this.stride,i*=e.stride;for(let o=0,n=this.stride;o<n;o++)this.array[A+o]=e.array[i+o];return this}set(A,e=0){return this.array.set(A,e),this}clone(A){A.arrayBuffers===void 0&&(A.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zy()),A.arrayBuffers[this.array.buffer._uuid]===void 0&&(A.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(A.arrayBuffers[this.array.buffer._uuid]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}onUpload(A){return this.onUploadCallback=A,this}toJSON(A){return A.arrayBuffers===void 0&&(A.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zy()),A.arrayBuffers[this.array.buffer._uuid]===void 0&&(A.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const pd=new _e;class iz{constructor(A,e,i,o=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=A,this.itemSize=e,this.offset=i,this.normalized=o}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(A){this.data.needsUpdate=A}applyMatrix4(A){for(let e=0,i=this.data.count;e<i;e++)pd.fromBufferAttribute(this,e),pd.applyMatrix4(A),this.setXYZ(e,pd.x,pd.y,pd.z);return this}applyNormalMatrix(A){for(let e=0,i=this.count;e<i;e++)pd.fromBufferAttribute(this,e),pd.applyNormalMatrix(A),this.setXYZ(e,pd.x,pd.y,pd.z);return this}transformDirection(A){for(let e=0,i=this.count;e<i;e++)pd.fromBufferAttribute(this,e),pd.transformDirection(A),this.setXYZ(e,pd.x,pd.y,pd.z);return this}getComponent(A,e){let i=this.array[A*this.data.stride+this.offset+e];return this.normalized&&(i=Vy(i,this.array)),i}setComponent(A,e,i){return this.normalized&&(i=Eg(i,this.array)),this.data.array[A*this.data.stride+this.offset+e]=i,this}setX(A,e){return this.normalized&&(e=Eg(e,this.array)),this.data.array[A*this.data.stride+this.offset]=e,this}setY(A,e){return this.normalized&&(e=Eg(e,this.array)),this.data.array[A*this.data.stride+this.offset+1]=e,this}setZ(A,e){return this.normalized&&(e=Eg(e,this.array)),this.data.array[A*this.data.stride+this.offset+2]=e,this}setW(A,e){return this.normalized&&(e=Eg(e,this.array)),this.data.array[A*this.data.stride+this.offset+3]=e,this}getX(A){let e=this.data.array[A*this.data.stride+this.offset];return this.normalized&&(e=Vy(e,this.array)),e}getY(A){let e=this.data.array[A*this.data.stride+this.offset+1];return this.normalized&&(e=Vy(e,this.array)),e}getZ(A){let e=this.data.array[A*this.data.stride+this.offset+2];return this.normalized&&(e=Vy(e,this.array)),e}getW(A){let e=this.data.array[A*this.data.stride+this.offset+3];return this.normalized&&(e=Vy(e,this.array)),e}setXY(A,e,i){return A=A*this.data.stride+this.offset,this.normalized&&(e=Eg(e,this.array),i=Eg(i,this.array)),this.data.array[A+0]=e,this.data.array[A+1]=i,this}setXYZ(A,e,i,o){return A=A*this.data.stride+this.offset,this.normalized&&(e=Eg(e,this.array),i=Eg(i,this.array),o=Eg(o,this.array)),this.data.array[A+0]=e,this.data.array[A+1]=i,this.data.array[A+2]=o,this}setXYZW(A,e,i,o,n){return A=A*this.data.stride+this.offset,this.normalized&&(e=Eg(e,this.array),i=Eg(i,this.array),o=Eg(o,this.array),n=Eg(n,this.array)),this.data.array[A+0]=e,this.data.array[A+1]=i,this.data.array[A+2]=o,this.data.array[A+3]=n,this}clone(A){if(A===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const o=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[o+n])}return new cI(new this.array.constructor(e),this.itemSize,this.normalized)}else return A.interleavedBuffers===void 0&&(A.interleavedBuffers={}),A.interleavedBuffers[this.data.uuid]===void 0&&(A.interleavedBuffers[this.data.uuid]=this.data.clone(A)),new iz(A.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(A){if(A===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const o=i*this.data.stride+this.offset;for(let n=0;n<this.itemSize;n++)e.push(this.data.array[o+n])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return A.interleavedBuffers===void 0&&(A.interleavedBuffers={}),A.interleavedBuffers[this.data.uuid]===void 0&&(A.interleavedBuffers[this.data.uuid]=this.data.toJSON(A)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}const lbA=new _e,QbA=new ug,EbA=new ug,KDe=new _e,hbA=new os,GK=new _e,oz=new Xy,ubA=new os,nz=new N_;class TDe extends on{constructor(A,e){super(A,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=pDA,this.bindMatrix=new os,this.bindMatrixInverse=new os,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const A=this.geometry;this.boundingBox===null&&(this.boundingBox=new jy),this.boundingBox.makeEmpty();const e=A.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,GK),this.boundingBox.expandByPoint(GK)}computeBoundingSphere(){const A=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Xy),this.boundingSphere.makeEmpty();const e=A.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,GK),this.boundingSphere.expandByPoint(GK)}copy(A,e){return super.copy(A,e),this.bindMode=A.bindMode,this.bindMatrix.copy(A.bindMatrix),this.bindMatrixInverse.copy(A.bindMatrixInverse),this.skeleton=A.skeleton,A.boundingBox!==null&&(this.boundingBox=A.boundingBox.clone()),A.boundingSphere!==null&&(this.boundingSphere=A.boundingSphere.clone()),this}raycast(A,e){const i=this.material,o=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),oz.copy(this.boundingSphere),oz.applyMatrix4(o),A.ray.intersectsSphere(oz)!==!1&&(ubA.copy(o).invert(),nz.copy(A.ray).applyMatrix4(ubA),!(this.boundingBox!==null&&nz.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(A,e,nz)))}getVertexPosition(A,e){return super.getVertexPosition(A,e),this.applyBoneTransform(A,e),e}bind(A,e){this.skeleton=A,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const A=new ug,e=this.geometry.attributes.skinWeight;for(let i=0,o=e.count;i<o;i++){A.fromBufferAttribute(e,i);const n=1/A.manhattanLength();n!==1/0?A.multiplyScalar(n):A.set(1,0,0,0),e.setXYZW(i,A.x,A.y,A.z,A.w)}}updateMatrixWorld(A){super.updateMatrixWorld(A),this.bindMode===pDA?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Rfe?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(A,e){const i=this.skeleton,o=this.geometry;QbA.fromBufferAttribute(o.attributes.skinIndex,A),EbA.fromBufferAttribute(o.attributes.skinWeight,A),lbA.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let n=0;n<4;n++){const s=EbA.getComponent(n);if(s!==0){const r=QbA.getComponent(n);hbA.multiplyMatrices(i.bones[r].matrixWorld,i.boneInverses[r]),e.addScaledVector(KDe.copy(lbA).applyMatrix4(hbA),s)}}return e.applyMatrix4(this.bindMatrixInverse)}}class dbA extends dg{constructor(){super(),this.isBone=!0,this.type="Bone"}}class sz extends Yc{constructor(A=null,e=1,i=1,o,n,s,r,a,g=hu,I=hu,c,B){super(null,s,r,a,g,I,o,n,c,B),this.isDataTexture=!0,this.image={data:A,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const pbA=new os,qDe=new os;class rz{constructor(A=[],e=[]){this.uuid=Zy(),this.bones=A.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const A=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(A.length*16),e.length===0)this.calculateInverses();else if(A.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,o=this.bones.length;i<o;i++)this.boneInverses.push(new os)}}calculateInverses(){this.boneInverses.length=0;for(let A=0,e=this.bones.length;A<e;A++){const i=new os;this.bones[A]&&i.copy(this.bones[A].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let A=0,e=this.bones.length;A<e;A++){const i=this.bones[A];i&&i.matrixWorld.copy(this.boneInverses[A]).invert()}for(let A=0,e=this.bones.length;A<e;A++){const i=this.bones[A];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const A=this.bones,e=this.boneInverses,i=this.boneMatrices,o=this.boneTexture;for(let n=0,s=A.length;n<s;n++){const r=A[n]?A[n].matrixWorld:qDe;pbA.multiplyMatrices(r,e[n]),pbA.toArray(i,n*16)}o!==null&&(o.needsUpdate=!0)}clone(){return new rz(this.bones,this.boneInverses)}computeBoneTexture(){let A=Math.sqrt(this.bones.length*4);A=Math.ceil(A/4)*4,A=Math.max(A,4);const e=new Float32Array(A*A*4);e.set(this.boneMatrices);const i=new sz(e,A,A,Z0,$m);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(A){for(let e=0,i=this.bones.length;e<i;e++){const o=this.bones[e];if(o.name===A)return o}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(A,e){this.uuid=A.uuid;for(let i=0,o=A.bones.length;i<o;i++){const n=A.bones[i];let s=e[n];s===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),s=new dbA),this.bones.push(s),this.boneInverses.push(new os().fromArray(A.boneInverses[i]))}return this.init(),this}toJSON(){const A={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};A.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let o=0,n=e.length;o<n;o++){const s=e[o];A.bones.push(s.uuid);const r=i[o];A.boneInverses.push(r.toArray())}return A}}class FK extends cI{constructor(A,e,i,o=1){super(A,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=o}copy(A){return super.copy(A),this.meshPerAttribute=A.meshPerAttribute,this}toJSON(){const A=super.toJSON();return A.meshPerAttribute=this.meshPerAttribute,A.isInstancedBufferAttribute=!0,A}}const j_=new os,fbA=new os,_K=[],ybA=new jy,PDe=new os,F1=new on,_1=new Xy;class ODe extends on{constructor(A,e,i){super(A,e),this.isInstancedMesh=!0,this.instanceMatrix=new FK(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let o=0;o<i;o++)this.setMatrixAt(o,PDe)}computeBoundingBox(){const A=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new jy),A.boundingBox===null&&A.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,j_),ybA.copy(A.boundingBox).applyMatrix4(j_),this.boundingBox.union(ybA)}computeBoundingSphere(){const A=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Xy),A.boundingSphere===null&&A.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,j_),_1.copy(A.boundingSphere).applyMatrix4(j_),this.boundingSphere.union(_1)}copy(A,e){return super.copy(A,e),this.instanceMatrix.copy(A.instanceMatrix),A.morphTexture!==null&&(this.morphTexture=A.morphTexture.clone()),A.instanceColor!==null&&(this.instanceColor=A.instanceColor.clone()),this.count=A.count,A.boundingBox!==null&&(this.boundingBox=A.boundingBox.clone()),A.boundingSphere!==null&&(this.boundingSphere=A.boundingSphere.clone()),this}getColorAt(A,e){e.fromArray(this.instanceColor.array,A*3)}getMatrixAt(A,e){e.fromArray(this.instanceMatrix.array,A*16)}getMorphAt(A,e){const i=e.morphTargetInfluences,o=this.morphTexture.source.data.data,n=i.length+1,s=A*n+1;for(let r=0;r<i.length;r++)i[r]=o[s+r]}raycast(A,e){const i=this.matrixWorld,o=this.count;if(F1.geometry=this.geometry,F1.material=this.material,F1.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),_1.copy(this.boundingSphere),_1.applyMatrix4(i),A.ray.intersectsSphere(_1)!==!1))for(let n=0;n<o;n++){this.getMatrixAt(n,j_),fbA.multiplyMatrices(i,j_),F1.matrixWorld=fbA,F1.raycast(A,_K);for(let s=0,r=_K.length;s<r;s++){const a=_K[s];a.instanceId=n,a.object=this,e.push(a)}_K.length=0}}setColorAt(A,e){this.instanceColor===null&&(this.instanceColor=new FK(new Float32Array(this.instanceMatrix.count*3),3)),e.toArray(this.instanceColor.array,A*3)}setMatrixAt(A,e){e.toArray(this.instanceMatrix.array,A*16)}setMorphAt(A,e){const i=e.morphTargetInfluences,o=i.length+1;this.morphTexture===null&&(this.morphTexture=new sz(new Float32Array(o*this.count),o,this.count,DDA,$m));const n=this.morphTexture.source.data.data;let s=0;for(let g=0;g<i.length;g++)s+=i[g];const r=this.geometry.morphTargetsRelative?1:1-s,a=o*A;n[a]=r,n.set(i,a+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class Ok extends Mp{constructor(A){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Li(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.color.copy(A.color),this.map=A.map,this.linewidth=A.linewidth,this.linecap=A.linecap,this.linejoin=A.linejoin,this.fog=A.fog,this}}const RK=new _e,NK=new _e,mbA=new os,R1=new N_,MK=new Xy,az=new _e,wbA=new _e;let gz=class extends dg{constructor(A=new Hg,e=new Ok){super(),this.isLine=!0,this.type="Line",this.geometry=A,this.material=e,this.updateMorphTargets()}copy(A,e){return super.copy(A,e),this.material=Array.isArray(A.material)?A.material.slice():A.material,this.geometry=A.geometry,this}computeLineDistances(){const A=this.geometry;if(A.index===null){const e=A.attributes.position,i=[0];for(let o=1,n=e.count;o<n;o++)RK.fromBufferAttribute(e,o-1),NK.fromBufferAttribute(e,o),i[o]=i[o-1],i[o]+=RK.distanceTo(NK);A.setAttribute("lineDistance",new ns(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(A,e){const i=this.geometry,o=this.matrixWorld,n=A.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),MK.copy(i.boundingSphere),MK.applyMatrix4(o),MK.radius+=n,A.ray.intersectsSphere(MK)===!1)return;mbA.copy(o).invert(),R1.copy(A.ray).applyMatrix4(mbA);const r=n/((this.scale.x+this.scale.y+this.scale.z)/3),a=r*r,g=this.isLineSegments?2:1,I=i.index,B=i.attributes.position;if(I!==null){const C=Math.max(0,s.start),l=Math.min(I.count,s.start+s.count);for(let Q=C,E=l-1;Q<E;Q+=g){const h=I.getX(Q),u=I.getX(Q+1),d=vK(this,A,R1,a,h,u);d&&e.push(d)}if(this.isLineLoop){const Q=I.getX(l-1),E=I.getX(C),h=vK(this,A,R1,a,Q,E);h&&e.push(h)}}else{const C=Math.max(0,s.start),l=Math.min(B.count,s.start+s.count);for(let Q=C,E=l-1;Q<E;Q+=g){const h=vK(this,A,R1,a,Q,Q+1);h&&e.push(h)}if(this.isLineLoop){const Q=vK(this,A,R1,a,l-1,C);Q&&e.push(Q)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const o=e[i[0]];if(o!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,s=o.length;n<s;n++){const r=o[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=n}}}}};function vK(t,A,e,i,o,n){const s=t.geometry.attributes.position;if(RK.fromBufferAttribute(s,o),NK.fromBufferAttribute(s,n),e.distanceSqToSegment(RK,NK,az,wbA)>i)return;az.applyMatrix4(t.matrixWorld);const a=A.ray.origin.distanceTo(az);if(!(a<A.near||a>A.far))return{distance:a,point:wbA.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,object:t}}const DbA=new _e,SbA=new _e;class N1 extends gz{constructor(A,e){super(A,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const A=this.geometry;if(A.index===null){const e=A.attributes.position,i=[];for(let o=0,n=e.count;o<n;o+=2)DbA.fromBufferAttribute(e,o),SbA.fromBufferAttribute(e,o+1),i[o]=o===0?0:i[o-1],i[o+1]=i[o]+DbA.distanceTo(SbA);A.setAttribute("lineDistance",new ns(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class WDe extends gz{constructor(A,e){super(A,e),this.isLineLoop=!0,this.type="LineLoop"}}class Wk extends Mp{constructor(A){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Li(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.color.copy(A.color),this.map=A.map,this.alphaMap=A.alphaMap,this.size=A.size,this.sizeAttenuation=A.sizeAttenuation,this.fog=A.fog,this}}const bbA=new os,Iz=new N_,UK=new Xy,LK=new _e;class M1 extends dg{constructor(A=new Hg,e=new Wk){super(),this.isPoints=!0,this.type="Points",this.geometry=A,this.material=e,this.updateMorphTargets()}copy(A,e){return super.copy(A,e),this.material=Array.isArray(A.material)?A.material.slice():A.material,this.geometry=A.geometry,this}raycast(A,e){const i=this.geometry,o=this.matrixWorld,n=A.params.Points.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),UK.copy(i.boundingSphere),UK.applyMatrix4(o),UK.radius+=n,A.ray.intersectsSphere(UK)===!1)return;bbA.copy(o).invert(),Iz.copy(A.ray).applyMatrix4(bbA);const r=n/((this.scale.x+this.scale.y+this.scale.z)/3),a=r*r,g=i.index,c=i.attributes.position;if(g!==null){const B=Math.max(0,s.start),C=Math.min(g.count,s.start+s.count);for(let l=B,Q=C;l<Q;l++){const E=g.getX(l);LK.fromBufferAttribute(c,E),xbA(LK,E,a,o,A,e,this)}}else{const B=Math.max(0,s.start),C=Math.min(c.count,s.start+s.count);for(let l=B,Q=C;l<Q;l++)LK.fromBufferAttribute(c,l),xbA(LK,l,a,o,A,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const o=e[i[0]];if(o!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,s=o.length;n<s;n++){const r=o[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=n}}}}}function xbA(t,A,e,i,o,n,s){const r=Iz.distanceSqToPoint(t);if(r<e){const a=new _e;Iz.closestPointToPoint(t,a),a.applyMatrix4(i);const g=o.ray.origin.distanceTo(a);if(g<o.near||g>o.far)return;n.push({distance:g,distanceToRay:Math.sqrt(r),point:a,index:A,face:null,object:s})}}class cz extends Yc{constructor(A,e,i,o,n,s,r,a,g,I,c,B){super(null,s,r,a,g,I,o,n,c,B),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=A,this.flipY=!1,this.generateMipmaps=!1}}class v1 extends Yc{constructor(A,e,i,o,n,s,r,a,g){super(A,e,i,o,n,s,r,a,g),this.isCanvasTexture=!0,this.needsUpdate=!0}}class HK extends Hg{constructor(A=1,e=1,i=1,o=32,n=1,s=!1,r=0,a=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:A,radiusBottom:e,height:i,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:r,thetaLength:a};const g=this;o=Math.floor(o),n=Math.floor(n);const I=[],c=[],B=[],C=[];let l=0;const Q=[],E=i/2;let h=0;u(),s===!1&&(A>0&&d(!0),e>0&&d(!1)),this.setIndex(I),this.setAttribute("position",new ns(c,3)),this.setAttribute("normal",new ns(B,3)),this.setAttribute("uv",new ns(C,2));function u(){const f=new _e,D=new _e;let w=0;const x=(e-A)/i;for(let b=0;b<=n;b++){const F=[],k=b/n,U=k*(e-A)+A;for(let N=0;N<=o;N++){const J=N/o,P=J*a+r,T=Math.sin(P),O=Math.cos(P);D.x=U*T,D.y=-k*i+E,D.z=U*O,c.push(D.x,D.y,D.z),f.set(T,x,O).normalize(),B.push(f.x,f.y,f.z),C.push(J,1-k),F.push(l++)}Q.push(F)}for(let b=0;b<o;b++)for(let F=0;F<n;F++){const k=Q[F][b],U=Q[F+1][b],N=Q[F+1][b+1],J=Q[F][b+1];I.push(k,U,J),I.push(U,N,J),w+=6}g.addGroup(h,w,0),h+=w}function d(f){const D=l,w=new Io,x=new _e;let b=0;const F=f===!0?A:e,k=f===!0?1:-1;for(let N=1;N<=o;N++)c.push(0,E*k,0),B.push(0,k,0),C.push(.5,.5),l++;const U=l;for(let N=0;N<=o;N++){const P=N/o*a+r,T=Math.cos(P),O=Math.sin(P);x.x=F*O,x.y=E*k,x.z=F*T,c.push(x.x,x.y,x.z),B.push(0,k,0),w.x=T*.5+.5,w.y=O*.5*k+.5,C.push(w.x,w.y),l++}for(let N=0;N<o;N++){const J=D+N,P=U+N;f===!0?I.push(P,P+1,J):I.push(P+1,P,J),b+=3}g.addGroup(h,b,f===!0?1:2),h+=b}}copy(A){return super.copy(A),this.parameters=Object.assign({},A.parameters),this}static fromJSON(A){return new HK(A.radiusTop,A.radiusBottom,A.height,A.radialSegments,A.heightSegments,A.openEnded,A.thetaStart,A.thetaLength)}}class Bz extends HK{constructor(A=1,e=1,i=32,o=1,n=!1,s=0,r=Math.PI*2){super(0,A,e,i,o,n,s,r),this.type="ConeGeometry",this.parameters={radius:A,height:e,radialSegments:i,heightSegments:o,openEnded:n,thetaStart:s,thetaLength:r}}static fromJSON(A){return new Bz(A.radius,A.height,A.radialSegments,A.heightSegments,A.openEnded,A.thetaStart,A.thetaLength)}}const YK=new _e,JK=new _e,Cz=new _e,KK=new em;class ZDe extends Hg{constructor(A=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:A,thresholdAngle:e},A!==null){const o=Math.pow(10,4),n=Math.cos(b_*e),s=A.getIndex(),r=A.getAttribute("position"),a=s?s.count:r.count,g=[0,0,0],I=["a","b","c"],c=new Array(3),B={},C=[];for(let l=0;l<a;l+=3){s?(g[0]=s.getX(l),g[1]=s.getX(l+1),g[2]=s.getX(l+2)):(g[0]=l,g[1]=l+1,g[2]=l+2);const{a:Q,b:E,c:h}=KK;if(Q.fromBufferAttribute(r,g[0]),E.fromBufferAttribute(r,g[1]),h.fromBufferAttribute(r,g[2]),KK.getNormal(Cz),c[0]=`${Math.round(Q.x*o)},${Math.round(Q.y*o)},${Math.round(Q.z*o)}`,c[1]=`${Math.round(E.x*o)},${Math.round(E.y*o)},${Math.round(E.z*o)}`,c[2]=`${Math.round(h.x*o)},${Math.round(h.y*o)},${Math.round(h.z*o)}`,!(c[0]===c[1]||c[1]===c[2]||c[2]===c[0]))for(let u=0;u<3;u++){const d=(u+1)%3,f=c[u],D=c[d],w=KK[I[u]],x=KK[I[d]],b=`${f}_${D}`,F=`${D}_${f}`;F in B&&B[F]?(Cz.dot(B[F].normal)<=n&&(C.push(w.x,w.y,w.z),C.push(x.x,x.y,x.z)),B[F]=null):b in B||(B[b]={index0:g[u],index1:g[d],normal:Cz.clone()})}}for(const l in B)if(B[l]){const{index0:Q,index1:E}=B[l];YK.fromBufferAttribute(r,Q),JK.fromBufferAttribute(r,E),C.push(YK.x,YK.y,YK.z),C.push(JK.x,JK.y,JK.z)}this.setAttribute("position",new ns(C,3))}}copy(A){return super.copy(A),this.parameters=Object.assign({},A.parameters),this}}const VDe={triangulate:function(t,A,e=2){const i=A&&A.length,o=i?A[0]*e:t.length;let n=kbA(t,0,o,e,!0);const s=[];if(!n||n.next===n.prev)return s;let r,a,g,I,c,B,C;if(i&&(n=ASe(t,A,n,e)),t.length>80*e){r=g=t[0],a=I=t[1];for(let l=e;l<o;l+=e)c=t[l],B=t[l+1],c<r&&(r=c),B<a&&(a=B),c>g&&(g=c),B>I&&(I=B);C=Math.max(g-r,I-a),C=C!==0?32767/C:0}return U1(n,s,e,r,a,C,0),s}};function kbA(t,A,e,i,o){let n,s;if(o===cSe(t,A,e,i)>0)for(n=A;n<e;n+=i)s=_bA(n,t[n],t[n+1],s);else for(n=e-i;n>=A;n-=i)s=_bA(n,t[n],t[n+1],s);return s&&TK(s,s.next)&&(H1(s),s=s.next),s}function Zk(t,A){if(!t)return t;A||(A=t);let e=t,i;do if(i=!1,!e.steiner&&(TK(e,e.next)||uB(e.prev,e,e.next)===0)){if(H1(e),e=A=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==A);return A}function U1(t,A,e,i,o,n,s){if(!t)return;!s&&n&&nSe(t,i,o,n);let r=t,a,g;for(;t.prev!==t.next;){if(a=t.prev,g=t.next,n?zDe(t,i,o,n):jDe(t)){A.push(a.i/e|0),A.push(t.i/e|0),A.push(g.i/e|0),H1(t),t=g.next,r=g.next;continue}if(t=g,t===r){s?s===1?(t=XDe(Zk(t),A,e),U1(t,A,e,i,o,n,2)):s===2&&$De(t,A,e,i,o,n):U1(Zk(t),A,e,i,o,n,1);break}}}function jDe(t){const A=t.prev,e=t,i=t.next;if(uB(A,e,i)>=0)return!1;const o=A.x,n=e.x,s=i.x,r=A.y,a=e.y,g=i.y,I=o<n?o<s?o:s:n<s?n:s,c=r<a?r<g?r:g:a<g?a:g,B=o>n?o>s?o:s:n>s?n:s,C=r>a?r>g?r:g:a>g?a:g;let l=i.next;for(;l!==A;){if(l.x>=I&&l.x<=B&&l.y>=c&&l.y<=C&&z_(o,r,n,a,s,g,l.x,l.y)&&uB(l.prev,l,l.next)>=0)return!1;l=l.next}return!0}function zDe(t,A,e,i){const o=t.prev,n=t,s=t.next;if(uB(o,n,s)>=0)return!1;const r=o.x,a=n.x,g=s.x,I=o.y,c=n.y,B=s.y,C=r<a?r<g?r:g:a<g?a:g,l=I<c?I<B?I:B:c<B?c:B,Q=r>a?r>g?r:g:a>g?a:g,E=I>c?I>B?I:B:c>B?c:B,h=lz(C,l,A,e,i),u=lz(Q,E,A,e,i);let d=t.prevZ,f=t.nextZ;for(;d&&d.z>=h&&f&&f.z<=u;){if(d.x>=C&&d.x<=Q&&d.y>=l&&d.y<=E&&d!==o&&d!==s&&z_(r,I,a,c,g,B,d.x,d.y)&&uB(d.prev,d,d.next)>=0||(d=d.prevZ,f.x>=C&&f.x<=Q&&f.y>=l&&f.y<=E&&f!==o&&f!==s&&z_(r,I,a,c,g,B,f.x,f.y)&&uB(f.prev,f,f.next)>=0))return!1;f=f.nextZ}for(;d&&d.z>=h;){if(d.x>=C&&d.x<=Q&&d.y>=l&&d.y<=E&&d!==o&&d!==s&&z_(r,I,a,c,g,B,d.x,d.y)&&uB(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=u;){if(f.x>=C&&f.x<=Q&&f.y>=l&&f.y<=E&&f!==o&&f!==s&&z_(r,I,a,c,g,B,f.x,f.y)&&uB(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function XDe(t,A,e){let i=t;do{const o=i.prev,n=i.next.next;!TK(o,n)&&GbA(o,i,i.next,n)&&L1(o,n)&&L1(n,o)&&(A.push(o.i/e|0),A.push(i.i/e|0),A.push(n.i/e|0),H1(i),H1(i.next),i=t=n),i=i.next}while(i!==t);return Zk(i)}function $De(t,A,e,i,o,n){let s=t;do{let r=s.next.next;for(;r!==s.prev;){if(s.i!==r.i&&aSe(s,r)){let a=FbA(s,r);s=Zk(s,s.next),a=Zk(a,a.next),U1(s,A,e,i,o,n,0),U1(a,A,e,i,o,n,0);return}r=r.next}s=s.next}while(s!==t)}function ASe(t,A,e,i){const o=[];let n,s,r,a,g;for(n=0,s=A.length;n<s;n++)r=A[n]*i,a=n<s-1?A[n+1]*i:t.length,g=kbA(t,r,a,i,!1),g===g.next&&(g.steiner=!0),o.push(rSe(g));for(o.sort(eSe),n=0;n<o.length;n++)e=tSe(o[n],e);return e}function eSe(t,A){return t.x-A.x}function tSe(t,A){const e=iSe(t,A);if(!e)return A;const i=FbA(e,t);return Zk(i,i.next),Zk(e,e.next)}function iSe(t,A){let e=A,i=-1/0,o;const n=t.x,s=t.y;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){const B=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(B<=n&&B>i&&(i=B,o=e.x<e.next.x?e:e.next,B===n))return o}e=e.next}while(e!==A);if(!o)return null;const r=o,a=o.x,g=o.y;let I=1/0,c;e=o;do n>=e.x&&e.x>=a&&n!==e.x&&z_(s<g?n:i,s,a,g,s<g?i:n,s,e.x,e.y)&&(c=Math.abs(s-e.y)/(n-e.x),L1(e,t)&&(c<I||c===I&&(e.x>o.x||e.x===o.x&&oSe(o,e)))&&(o=e,I=c)),e=e.next;while(e!==r);return o}function oSe(t,A){return uB(t.prev,t,A.prev)<0&&uB(A.next,t,t.next)<0}function nSe(t,A,e,i){let o=t;do o.z===0&&(o.z=lz(o.x,o.y,A,e,i)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,sSe(o)}function sSe(t){let A,e,i,o,n,s,r,a,g=1;do{for(e=t,t=null,n=null,s=0;e;){for(s++,i=e,r=0,A=0;A<g&&(r++,i=i.nextZ,!!i);A++);for(a=g;r>0||a>0&&i;)r!==0&&(a===0||!i||e.z<=i.z)?(o=e,e=e.nextZ,r--):(o=i,i=i.nextZ,a--),n?n.nextZ=o:t=o,o.prevZ=n,n=o;e=i}n.nextZ=null,g*=2}while(s>1);return t}function lz(t,A,e,i,o){return t=(t-e)*o|0,A=(A-i)*o|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,A=(A|A<<8)&16711935,A=(A|A<<4)&252645135,A=(A|A<<2)&858993459,A=(A|A<<1)&1431655765,t|A<<1}function rSe(t){let A=t,e=t;do(A.x<e.x||A.x===e.x&&A.y<e.y)&&(e=A),A=A.next;while(A!==t);return e}function z_(t,A,e,i,o,n,s,r){return(o-s)*(A-r)>=(t-s)*(n-r)&&(t-s)*(i-r)>=(e-s)*(A-r)&&(e-s)*(n-r)>=(o-s)*(i-r)}function aSe(t,A){return t.next.i!==A.i&&t.prev.i!==A.i&&!gSe(t,A)&&(L1(t,A)&&L1(A,t)&&ISe(t,A)&&(uB(t.prev,t,A.prev)||uB(t,A.prev,A))||TK(t,A)&&uB(t.prev,t,t.next)>0&&uB(A.prev,A,A.next)>0)}function uB(t,A,e){return(A.y-t.y)*(e.x-A.x)-(A.x-t.x)*(e.y-A.y)}function TK(t,A){return t.x===A.x&&t.y===A.y}function GbA(t,A,e,i){const o=PK(uB(t,A,e)),n=PK(uB(t,A,i)),s=PK(uB(e,i,t)),r=PK(uB(e,i,A));return!!(o!==n&&s!==r||o===0&&qK(t,e,A)||n===0&&qK(t,i,A)||s===0&&qK(e,t,i)||r===0&&qK(e,A,i))}function qK(t,A,e){return A.x<=Math.max(t.x,e.x)&&A.x>=Math.min(t.x,e.x)&&A.y<=Math.max(t.y,e.y)&&A.y>=Math.min(t.y,e.y)}function PK(t){return t>0?1:t<0?-1:0}function gSe(t,A){let e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==A.i&&e.next.i!==A.i&&GbA(e,e.next,t,A))return!0;e=e.next}while(e!==t);return!1}function L1(t,A){return uB(t.prev,t,t.next)<0?uB(t,A,t.next)>=0&&uB(t,t.prev,A)>=0:uB(t,A,t.prev)<0||uB(t,t.next,A)<0}function ISe(t,A){let e=t,i=!1;const o=(t.x+A.x)/2,n=(t.y+A.y)/2;do e.y>n!=e.next.y>n&&e.next.y!==e.y&&o<(e.next.x-e.x)*(n-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==t);return i}function FbA(t,A){const e=new Qz(t.i,t.x,t.y),i=new Qz(A.i,A.x,A.y),o=t.next,n=A.prev;return t.next=A,A.prev=t,e.next=o,o.prev=e,i.next=e,e.prev=i,n.next=i,i.prev=n,i}function _bA(t,A,e,i){const o=new Qz(t,A,e);return i?(o.next=i.next,o.prev=i,i.next.prev=o,i.next=o):(o.prev=o,o.next=o),o}function H1(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Qz(t,A,e){this.i=t,this.x=A,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function cSe(t,A,e,i){let o=0;for(let n=A,s=e-i;n<e;n+=i)o+=(t[s]-t[n])*(t[n+1]+t[s+1]),s=n;return o}class Ez{static area(A){const e=A.length;let i=0;for(let o=e-1,n=0;n<e;o=n++)i+=A[o].x*A[n].y-A[n].x*A[o].y;return i*.5}static isClockWise(A){return Ez.area(A)<0}static triangulateShape(A,e){const i=[],o=[],n=[];RbA(A),NbA(i,A);let s=A.length;e.forEach(RbA);for(let a=0;a<e.length;a++)o.push(s),s+=e[a].length,NbA(i,e[a]);const r=VDe.triangulate(i,o);for(let a=0;a<r.length;a+=3)n.push(r.slice(a,a+3));return n}}function RbA(t){const A=t.length;A>2&&t[A-1].equals(t[0])&&t.pop()}function NbA(t,A){for(let e=0;e<A.length;e++)t.push(A[e].x),t.push(A[e].y)}class Y1 extends Hg{constructor(A=1,e=32,i=16,o=0,n=Math.PI*2,s=0,r=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:A,widthSegments:e,heightSegments:i,phiStart:o,phiLength:n,thetaStart:s,thetaLength:r},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const a=Math.min(s+r,Math.PI);let g=0;const I=[],c=new _e,B=new _e,C=[],l=[],Q=[],E=[];for(let h=0;h<=i;h++){const u=[],d=h/i;let f=0;h===0&&s===0?f=.5/e:h===i&&a===Math.PI&&(f=-.5/e);for(let D=0;D<=e;D++){const w=D/e;c.x=-A*Math.cos(o+w*n)*Math.sin(s+d*r),c.y=A*Math.cos(s+d*r),c.z=A*Math.sin(o+w*n)*Math.sin(s+d*r),l.push(c.x,c.y,c.z),B.copy(c).normalize(),Q.push(B.x,B.y,B.z),E.push(w+f,1-d),u.push(g++)}I.push(u)}for(let h=0;h<i;h++)for(let u=0;u<e;u++){const d=I[h][u+1],f=I[h][u],D=I[h+1][u],w=I[h+1][u+1];(h!==0||s>0)&&C.push(d,f,w),(h!==i-1||a<Math.PI)&&C.push(f,D,w)}this.setIndex(C),this.setAttribute("position",new ns(l,3)),this.setAttribute("normal",new ns(Q,3)),this.setAttribute("uv",new ns(E,2))}copy(A){return super.copy(A),this.parameters=Object.assign({},A.parameters),this}static fromJSON(A){return new Y1(A.radius,A.widthSegments,A.heightSegments,A.phiStart,A.phiLength,A.thetaStart,A.thetaLength)}}class pu extends Mp{constructor(A){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Li(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Li(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fj,this.normalScale=new Io(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Np,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.defines={STANDARD:""},this.color.copy(A.color),this.roughness=A.roughness,this.metalness=A.metalness,this.map=A.map,this.lightMap=A.lightMap,this.lightMapIntensity=A.lightMapIntensity,this.aoMap=A.aoMap,this.aoMapIntensity=A.aoMapIntensity,this.emissive.copy(A.emissive),this.emissiveMap=A.emissiveMap,this.emissiveIntensity=A.emissiveIntensity,this.bumpMap=A.bumpMap,this.bumpScale=A.bumpScale,this.normalMap=A.normalMap,this.normalMapType=A.normalMapType,this.normalScale.copy(A.normalScale),this.displacementMap=A.displacementMap,this.displacementScale=A.displacementScale,this.displacementBias=A.displacementBias,this.roughnessMap=A.roughnessMap,this.metalnessMap=A.metalnessMap,this.alphaMap=A.alphaMap,this.envMap=A.envMap,this.envMapRotation.copy(A.envMapRotation),this.envMapIntensity=A.envMapIntensity,this.wireframe=A.wireframe,this.wireframeLinewidth=A.wireframeLinewidth,this.wireframeLinecap=A.wireframeLinecap,this.wireframeLinejoin=A.wireframeLinejoin,this.flatShading=A.flatShading,this.fog=A.fog,this}}class om extends pu{constructor(A){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Io(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ah(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Li(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Li(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Li(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(A)}get anisotropy(){return this._anisotropy}set anisotropy(A){this._anisotropy>0!=A>0&&this.version++,this._anisotropy=A}get clearcoat(){return this._clearcoat}set clearcoat(A){this._clearcoat>0!=A>0&&this.version++,this._clearcoat=A}get iridescence(){return this._iridescence}set iridescence(A){this._iridescence>0!=A>0&&this.version++,this._iridescence=A}get dispersion(){return this._dispersion}set dispersion(A){this._dispersion>0!=A>0&&this.version++,this._dispersion=A}get sheen(){return this._sheen}set sheen(A){this._sheen>0!=A>0&&this.version++,this._sheen=A}get transmission(){return this._transmission}set transmission(A){this._transmission>0!=A>0&&this.version++,this._transmission=A}copy(A){return super.copy(A),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=A.anisotropy,this.anisotropyRotation=A.anisotropyRotation,this.anisotropyMap=A.anisotropyMap,this.clearcoat=A.clearcoat,this.clearcoatMap=A.clearcoatMap,this.clearcoatRoughness=A.clearcoatRoughness,this.clearcoatRoughnessMap=A.clearcoatRoughnessMap,this.clearcoatNormalMap=A.clearcoatNormalMap,this.clearcoatNormalScale.copy(A.clearcoatNormalScale),this.dispersion=A.dispersion,this.ior=A.ior,this.iridescence=A.iridescence,this.iridescenceMap=A.iridescenceMap,this.iridescenceIOR=A.iridescenceIOR,this.iridescenceThicknessRange=[...A.iridescenceThicknessRange],this.iridescenceThicknessMap=A.iridescenceThicknessMap,this.sheen=A.sheen,this.sheenColor.copy(A.sheenColor),this.sheenColorMap=A.sheenColorMap,this.sheenRoughness=A.sheenRoughness,this.sheenRoughnessMap=A.sheenRoughnessMap,this.transmission=A.transmission,this.transmissionMap=A.transmissionMap,this.thickness=A.thickness,this.thicknessMap=A.thicknessMap,this.attenuationDistance=A.attenuationDistance,this.attenuationColor.copy(A.attenuationColor),this.specularIntensity=A.specularIntensity,this.specularIntensityMap=A.specularIntensityMap,this.specularColor.copy(A.specularColor),this.specularColorMap=A.specularColorMap,this}}class hz extends Mp{constructor(A){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Li(16777215),this.specular=new Li(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Li(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=fj,this.normalScale=new Io(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Np,this.combine=cj,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.color.copy(A.color),this.specular.copy(A.specular),this.shininess=A.shininess,this.map=A.map,this.lightMap=A.lightMap,this.lightMapIntensity=A.lightMapIntensity,this.aoMap=A.aoMap,this.aoMapIntensity=A.aoMapIntensity,this.emissive.copy(A.emissive),this.emissiveMap=A.emissiveMap,this.emissiveIntensity=A.emissiveIntensity,this.bumpMap=A.bumpMap,this.bumpScale=A.bumpScale,this.normalMap=A.normalMap,this.normalMapType=A.normalMapType,this.normalScale.copy(A.normalScale),this.displacementMap=A.displacementMap,this.displacementScale=A.displacementScale,this.displacementBias=A.displacementBias,this.specularMap=A.specularMap,this.alphaMap=A.alphaMap,this.envMap=A.envMap,this.envMapRotation.copy(A.envMapRotation),this.combine=A.combine,this.reflectivity=A.reflectivity,this.refractionRatio=A.refractionRatio,this.wireframe=A.wireframe,this.wireframeLinewidth=A.wireframeLinewidth,this.wireframeLinecap=A.wireframeLinecap,this.wireframeLinejoin=A.wireframeLinejoin,this.flatShading=A.flatShading,this.fog=A.fog,this}}function OK(t,A,e){return!t||!e&&t.constructor===A?t:typeof A.BYTES_PER_ELEMENT=="number"?new A(t):Array.prototype.slice.call(t)}function BSe(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function CSe(t){function A(o,n){return t[o]-t[n]}const e=t.length,i=new Array(e);for(let o=0;o!==e;++o)i[o]=o;return i.sort(A),i}function MbA(t,A,e){const i=t.length,o=new t.constructor(i);for(let n=0,s=0;s!==i;++n){const r=e[n]*A;for(let a=0;a!==A;++a)o[s++]=t[r+a]}return o}function vbA(t,A,e,i){let o=1,n=t[0];for(;n!==void 0&&n[i]===void 0;)n=t[o++];if(n===void 0)return;let s=n[i];if(s!==void 0)if(Array.isArray(s))do s=n[i],s!==void 0&&(A.push(n.time),e.push.apply(e,s)),n=t[o++];while(n!==void 0);else if(s.toArray!==void 0)do s=n[i],s!==void 0&&(A.push(n.time),s.toArray(e,e.length)),n=t[o++];while(n!==void 0);else do s=n[i],s!==void 0&&(A.push(n.time),e.push(s)),n=t[o++];while(n!==void 0)}class J1{constructor(A,e,i,o){this.parameterPositions=A,this._cachedIndex=0,this.resultBuffer=o!==void 0?o:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(A){const e=this.parameterPositions;let i=this._cachedIndex,o=e[i],n=e[i-1];A:{e:{let s;t:{i:if(!(A<o)){for(let r=i+2;;){if(o===void 0){if(A<n)break i;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===r)break;if(n=o,o=e[++i],A<o)break e}s=e.length;break t}if(!(A>=n)){const r=e[1];A<r&&(i=2,n=r);for(let a=i-2;;){if(n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===a)break;if(o=n,n=e[--i-1],A>=n)break e}s=i,i=0;break t}break A}for(;i<s;){const r=i+s>>>1;A<e[r]?s=r:i=r+1}if(o=e[i],n=e[i-1],n===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(o===void 0)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,n,o)}return this.interpolate_(i,n,A,o)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(A){const e=this.resultBuffer,i=this.sampleValues,o=this.valueSize,n=A*o;for(let s=0;s!==o;++s)e[s]=i[n+s];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class lSe extends J1{constructor(A,e,i,o){super(A,e,i,o),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:eSA,endingEnd:eSA}}intervalChanged_(A,e,i){const o=this.parameterPositions;let n=A-2,s=A+1,r=o[n],a=o[s];if(r===void 0)switch(this.getSettings_().endingStart){case tSA:n=A,r=2*e-i;break;case iSA:n=o.length-2,r=e+o[n]-o[n+1];break;default:n=A,r=i}if(a===void 0)switch(this.getSettings_().endingEnd){case tSA:s=A,a=2*i-e;break;case iSA:s=1,a=i+o[1]-o[0];break;default:s=A-1,a=e}const g=(i-e)*.5,I=this.valueSize;this._weightPrev=g/(e-r),this._weightNext=g/(a-i),this._offsetPrev=n*I,this._offsetNext=s*I}interpolate_(A,e,i,o){const n=this.resultBuffer,s=this.sampleValues,r=this.valueSize,a=A*r,g=a-r,I=this._offsetPrev,c=this._offsetNext,B=this._weightPrev,C=this._weightNext,l=(i-e)/(o-e),Q=l*l,E=Q*l,h=-B*E+2*B*Q-B*l,u=(1+B)*E+(-1.5-2*B)*Q+(-.5+B)*l+1,d=(-1-C)*E+(1.5+C)*Q+.5*l,f=C*E-C*Q;for(let D=0;D!==r;++D)n[D]=h*s[I+D]+u*s[g+D]+d*s[a+D]+f*s[c+D];return n}}class QSe extends J1{constructor(A,e,i,o){super(A,e,i,o)}interpolate_(A,e,i,o){const n=this.resultBuffer,s=this.sampleValues,r=this.valueSize,a=A*r,g=a-r,I=(i-e)/(o-e),c=1-I;for(let B=0;B!==r;++B)n[B]=s[g+B]*c+s[a+B]*I;return n}}class ESe extends J1{constructor(A,e,i,o){super(A,e,i,o)}interpolate_(A){return this.copySampleValue_(A-1)}}class tw{constructor(A,e,i,o){if(A===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+A);this.name=A,this.times=OK(e,this.TimeBufferType),this.values=OK(i,this.ValueBufferType),this.setInterpolation(o||this.DefaultInterpolation)}static toJSON(A){const e=A.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(A);else{i={name:A.name,times:OK(A.times,Array),values:OK(A.values,Array)};const o=A.getInterpolation();o!==A.DefaultInterpolation&&(i.interpolation=o)}return i.type=A.ValueTypeName,i}InterpolantFactoryMethodDiscrete(A){return new ESe(this.times,this.values,this.getValueSize(),A)}InterpolantFactoryMethodLinear(A){return new QSe(this.times,this.values,this.getValueSize(),A)}InterpolantFactoryMethodSmooth(A){return new lSe(this.times,this.values,this.getValueSize(),A)}setInterpolation(A){let e;switch(A){case w_:e=this.InterpolantFactoryMethodDiscrete;break;case D_:e=this.InterpolantFactoryMethodLinear;break;case dj:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(A!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return w_;case this.InterpolantFactoryMethodLinear:return D_;case this.InterpolantFactoryMethodSmooth:return dj}}getValueSize(){return this.values.length/this.times.length}shift(A){if(A!==0){const e=this.times;for(let i=0,o=e.length;i!==o;++i)e[i]+=A}return this}scale(A){if(A!==1){const e=this.times;for(let i=0,o=e.length;i!==o;++i)e[i]*=A}return this}trim(A,e){const i=this.times,o=i.length;let n=0,s=o-1;for(;n!==o&&i[n]<A;)++n;for(;s!==-1&&i[s]>e;)--s;if(++s,n!==0||s!==o){n>=s&&(s=Math.max(s,1),n=s-1);const r=this.getValueSize();this.times=i.slice(n,s),this.values=this.values.slice(n*r,s*r)}return this}validate(){let A=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),A=!1);const i=this.times,o=this.values,n=i.length;n===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),A=!1);let s=null;for(let r=0;r!==n;r++){const a=i[r];if(typeof a=="number"&&isNaN(a)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,r,a),A=!1;break}if(s!==null&&s>a){console.error("THREE.KeyframeTrack: Out of order keys.",this,r,a,s),A=!1;break}s=a}if(o!==void 0&&BSe(o))for(let r=0,a=o.length;r!==a;++r){const g=o[r];if(isNaN(g)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,r,g),A=!1;break}}return A}optimize(){const A=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),o=this.getInterpolation()===dj,n=A.length-1;let s=1;for(let r=1;r<n;++r){let a=!1;const g=A[r],I=A[r+1];if(g!==I&&(r!==1||g!==A[0]))if(o)a=!0;else{const c=r*i,B=c-i,C=c+i;for(let l=0;l!==i;++l){const Q=e[c+l];if(Q!==e[B+l]||Q!==e[C+l]){a=!0;break}}}if(a){if(r!==s){A[s]=A[r];const c=r*i,B=s*i;for(let C=0;C!==i;++C)e[B+C]=e[c+C]}++s}}if(n>0){A[s]=A[n];for(let r=n*i,a=s*i,g=0;g!==i;++g)e[a+g]=e[r+g];++s}return s!==A.length?(this.times=A.slice(0,s),this.values=e.slice(0,s*i)):(this.times=A,this.values=e),this}clone(){const A=this.times.slice(),e=this.values.slice(),i=this.constructor,o=new i(this.name,A,e);return o.createInterpolant=this.createInterpolant,o}}tw.prototype.TimeBufferType=Float32Array,tw.prototype.ValueBufferType=Float32Array,tw.prototype.DefaultInterpolation=D_;class X_ extends tw{constructor(A,e,i){super(A,e,i)}}X_.prototype.ValueTypeName="bool",X_.prototype.ValueBufferType=Array,X_.prototype.DefaultInterpolation=w_,X_.prototype.InterpolantFactoryMethodLinear=void 0,X_.prototype.InterpolantFactoryMethodSmooth=void 0;class UbA extends tw{}UbA.prototype.ValueTypeName="color";class $_ extends tw{}$_.prototype.ValueTypeName="number";class hSe extends J1{constructor(A,e,i,o){super(A,e,i,o)}interpolate_(A,e,i,o){const n=this.resultBuffer,s=this.sampleValues,r=this.valueSize,a=(i-e)/(o-e);let g=A*r;for(let I=g+r;g!==I;g+=4)hd.slerpFlat(n,0,s,g-r,s,g,a);return n}}class AR extends tw{InterpolantFactoryMethodLinear(A){return new hSe(this.times,this.values,this.getValueSize(),A)}}AR.prototype.ValueTypeName="quaternion",AR.prototype.InterpolantFactoryMethodSmooth=void 0;class eR extends tw{constructor(A,e,i){super(A,e,i)}}eR.prototype.ValueTypeName="string",eR.prototype.ValueBufferType=Array,eR.prototype.DefaultInterpolation=w_,eR.prototype.InterpolantFactoryMethodLinear=void 0,eR.prototype.InterpolantFactoryMethodSmooth=void 0;class tR extends tw{}tR.prototype.ValueTypeName="vector";class uSe{constructor(A="",e=-1,i=[],o=Tfe){this.name=A,this.tracks=i,this.duration=e,this.blendMode=o,this.uuid=Zy(),this.duration<0&&this.resetDuration()}static parse(A){const e=[],i=A.tracks,o=1/(A.fps||1);for(let s=0,r=i.length;s!==r;++s)e.push(pSe(i[s]).scale(o));const n=new this(A.name,A.duration,e,A.blendMode);return n.uuid=A.uuid,n}static toJSON(A){const e=[],i=A.tracks,o={name:A.name,duration:A.duration,tracks:e,uuid:A.uuid,blendMode:A.blendMode};for(let n=0,s=i.length;n!==s;++n)e.push(tw.toJSON(i[n]));return o}static CreateFromMorphTargetSequence(A,e,i,o){const n=e.length,s=[];for(let r=0;r<n;r++){let a=[],g=[];a.push((r+n-1)%n,r,(r+1)%n),g.push(0,1,0);const I=CSe(a);a=MbA(a,1,I),g=MbA(g,1,I),!o&&a[0]===0&&(a.push(n),g.push(g[0])),s.push(new $_(".morphTargetInfluences["+e[r].name+"]",a,g).scale(1/i))}return new this(A,-1,s)}static findByName(A,e){let i=A;if(!Array.isArray(A)){const o=A;i=o.geometry&&o.geometry.animations||o.animations}for(let o=0;o<i.length;o++)if(i[o].name===e)return i[o];return null}static CreateClipsFromMorphTargetSequences(A,e,i){const o={},n=/^([\w-]*?)([\d]+)$/;for(let r=0,a=A.length;r<a;r++){const g=A[r],I=g.name.match(n);if(I&&I.length>1){const c=I[1];let B=o[c];B||(o[c]=B=[]),B.push(g)}}const s=[];for(const r in o)s.push(this.CreateFromMorphTargetSequence(r,o[r],e,i));return s}static parseAnimation(A,e){if(!A)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(c,B,C,l,Q){if(C.length!==0){const E=[],h=[];vbA(C,E,h,l),E.length!==0&&Q.push(new c(B,E,h))}},o=[],n=A.name||"default",s=A.fps||30,r=A.blendMode;let a=A.length||-1;const g=A.hierarchy||[];for(let c=0;c<g.length;c++){const B=g[c].keys;if(!(!B||B.length===0))if(B[0].morphTargets){const C={};let l;for(l=0;l<B.length;l++)if(B[l].morphTargets)for(let Q=0;Q<B[l].morphTargets.length;Q++)C[B[l].morphTargets[Q]]=-1;for(const Q in C){const E=[],h=[];for(let u=0;u!==B[l].morphTargets.length;++u){const d=B[l];E.push(d.time),h.push(d.morphTarget===Q?1:0)}o.push(new $_(".morphTargetInfluence["+Q+"]",E,h))}a=C.length*s}else{const C=".bones["+e[c].name+"]";i(tR,C+".position",B,"pos",o),i(AR,C+".quaternion",B,"rot",o),i(tR,C+".scale",B,"scl",o)}}return o.length===0?null:new this(n,a,o,r)}resetDuration(){const A=this.tracks;let e=0;for(let i=0,o=A.length;i!==o;++i){const n=this.tracks[i];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let A=0;A<this.tracks.length;A++)this.tracks[A].trim(0,this.duration);return this}validate(){let A=!0;for(let e=0;e<this.tracks.length;e++)A=A&&this.tracks[e].validate();return A}optimize(){for(let A=0;A<this.tracks.length;A++)this.tracks[A].optimize();return this}clone(){const A=[];for(let e=0;e<this.tracks.length;e++)A.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,A,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function dSe(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return $_;case"vector":case"vector2":case"vector3":case"vector4":return tR;case"color":return UbA;case"quaternion":return AR;case"bool":case"boolean":return X_;case"string":return eR}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}function pSe(t){if(t.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const A=dSe(t.type);if(t.times===void 0){const e=[],i=[];vbA(t.keys,e,i,"value"),t.times=e,t.values=i}return A.parse!==void 0?A.parse(t):new A(t.name,t.times,t.values,t.interpolation)}const Db={enabled:!1,files:{},add:function(t,A){this.enabled!==!1&&(this.files[t]=A)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class fSe{constructor(A,e,i){const o=this;let n=!1,s=0,r=0,a;const g=[];this.onStart=void 0,this.onLoad=A,this.onProgress=e,this.onError=i,this.itemStart=function(I){r++,n===!1&&o.onStart!==void 0&&o.onStart(I,s,r),n=!0},this.itemEnd=function(I){s++,o.onProgress!==void 0&&o.onProgress(I,s,r),s===r&&(n=!1,o.onLoad!==void 0&&o.onLoad())},this.itemError=function(I){o.onError!==void 0&&o.onError(I)},this.resolveURL=function(I){return a?a(I):I},this.setURLModifier=function(I){return a=I,this},this.addHandler=function(I,c){return g.push(I,c),this},this.removeHandler=function(I){const c=g.indexOf(I);return c!==-1&&g.splice(c,2),this},this.getHandler=function(I){for(let c=0,B=g.length;c<B;c+=2){const C=g[c],l=g[c+1];if(C.global&&(C.lastIndex=0),C.test(I))return l}return null}}}const LbA=new fSe;class iw{constructor(A){this.manager=A!==void 0?A:LbA,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(A,e){const i=this;return new Promise(function(o,n){i.load(A,o,e,n)})}parse(){}setCrossOrigin(A){return this.crossOrigin=A,this}setWithCredentials(A){return this.withCredentials=A,this}setPath(A){return this.path=A,this}setResourcePath(A){return this.resourcePath=A,this}setRequestHeader(A){return this.requestHeader=A,this}}iw.DEFAULT_MATERIAL_NAME="__DEFAULT";const ND={};class ySe extends Error{constructor(A,e){super(A),this.response=e}}class iR extends iw{constructor(A){super(A)}load(A,e,i,o){A===void 0&&(A=""),this.path!==void 0&&(A=this.path+A),A=this.manager.resolveURL(A);const n=Db.get(A);if(n!==void 0)return this.manager.itemStart(A),setTimeout(()=>{e&&e(n),this.manager.itemEnd(A)},0),n;if(ND[A]!==void 0){ND[A].push({onLoad:e,onProgress:i,onError:o});return}ND[A]=[],ND[A].push({onLoad:e,onProgress:i,onError:o});const s=new Request(A,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),r=this.mimeType,a=this.responseType;fetch(s).then(g=>{if(g.status===200||g.status===0){if(g.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||g.body===void 0||g.body.getReader===void 0)return g;const I=ND[A],c=g.body.getReader(),B=g.headers.get("X-File-Size")||g.headers.get("Content-Length"),C=B?parseInt(B):0,l=C!==0;let Q=0;const E=new ReadableStream({start(h){u();function u(){c.read().then(({done:d,value:f})=>{if(d)h.close();else{Q+=f.byteLength;const D=new ProgressEvent("progress",{lengthComputable:l,loaded:Q,total:C});for(let w=0,x=I.length;w<x;w++){const b=I[w];b.onProgress&&b.onProgress(D)}h.enqueue(f),u()}},d=>{h.error(d)})}}});return new Response(E)}else throw new ySe(`fetch for "${g.url}" responded with ${g.status}: ${g.statusText}`,g)}).then(g=>{switch(a){case"arraybuffer":return g.arrayBuffer();case"blob":return g.blob();case"document":return g.text().then(I=>new DOMParser().parseFromString(I,r));case"json":return g.json();default:if(r===void 0)return g.text();{const c=/charset="?([^;"\s]*)"?/i.exec(r),B=c&&c[1]?c[1].toLowerCase():void 0,C=new TextDecoder(B);return g.arrayBuffer().then(l=>C.decode(l))}}}).then(g=>{Db.add(A,g);const I=ND[A];delete ND[A];for(let c=0,B=I.length;c<B;c++){const C=I[c];C.onLoad&&C.onLoad(g)}}).catch(g=>{const I=ND[A];if(I===void 0)throw this.manager.itemError(A),g;delete ND[A];for(let c=0,B=I.length;c<B;c++){const C=I[c];C.onError&&C.onError(g)}this.manager.itemError(A)}).finally(()=>{this.manager.itemEnd(A)}),this.manager.itemStart(A)}setResponseType(A){return this.responseType=A,this}setMimeType(A){return this.mimeType=A,this}}class mSe extends iw{constructor(A){super(A)}load(A,e,i,o){this.path!==void 0&&(A=this.path+A),A=this.manager.resolveURL(A);const n=this,s=Db.get(A);if(s!==void 0)return n.manager.itemStart(A),setTimeout(function(){e&&e(s),n.manager.itemEnd(A)},0),s;const r=w1("img");function a(){I(),Db.add(A,this),e&&e(this),n.manager.itemEnd(A)}function g(c){I(),o&&o(c),n.manager.itemError(A),n.manager.itemEnd(A)}function I(){r.removeEventListener("load",a,!1),r.removeEventListener("error",g,!1)}return r.addEventListener("load",a,!1),r.addEventListener("error",g,!1),A.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(r.crossOrigin=this.crossOrigin),n.manager.itemStart(A),r.src=A,r}}class uz extends iw{constructor(A){super(A)}load(A,e,i,o){const n=new Yc,s=new mSe(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(A,function(r){n.image=r,n.needsUpdate=!0,e!==void 0&&e(n)},i,o),n}}class WK extends dg{constructor(A,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Li(A),this.intensity=e}dispose(){}copy(A,e){return super.copy(A,e),this.color.copy(A.color),this.intensity=A.intensity,this}toJSON(A){const e=super.toJSON(A);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}}const dz=new os,HbA=new _e,YbA=new _e;class pz{constructor(A){this.camera=A,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Io(512,512),this.map=null,this.mapPass=null,this.matrix=new os,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Oj,this._frameExtents=new Io(1,1),this._viewportCount=1,this._viewports=[new ug(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(A){const e=this.camera,i=this.matrix;HbA.setFromMatrixPosition(A.matrixWorld),e.position.copy(HbA),YbA.setFromMatrixPosition(A.target.matrixWorld),e.lookAt(YbA),e.updateMatrixWorld(),dz.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dz),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(dz)}getViewport(A){return this._viewports[A]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(A){return this.camera=A.camera.clone(),this.bias=A.bias,this.radius=A.radius,this.mapSize.copy(A.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const A={};return this.bias!==0&&(A.bias=this.bias),this.normalBias!==0&&(A.normalBias=this.normalBias),this.radius!==1&&(A.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(A.mapSize=this.mapSize.toArray()),A.camera=this.camera.toJSON(!1).object,delete A.camera.matrix,A}}class wSe extends pz{constructor(){super(new sE(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(A){const e=this.camera,i=x_*2*A.angle*this.focus,o=this.mapSize.width/this.mapSize.height,n=A.distance||e.far;(i!==e.fov||o!==e.aspect||n!==e.far)&&(e.fov=i,e.aspect=o,e.far=n,e.updateProjectionMatrix()),super.updateMatrices(A)}copy(A){return super.copy(A),this.focus=A.focus,this}}class DSe extends WK{constructor(A,e,i=0,o=Math.PI/3,n=0,s=2){super(A,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(dg.DEFAULT_UP),this.updateMatrix(),this.target=new dg,this.distance=i,this.angle=o,this.penumbra=n,this.decay=s,this.map=null,this.shadow=new wSe}get power(){return this.intensity*Math.PI}set power(A){this.intensity=A/Math.PI}dispose(){this.shadow.dispose()}copy(A,e){return super.copy(A,e),this.distance=A.distance,this.angle=A.angle,this.penumbra=A.penumbra,this.decay=A.decay,this.target=A.target.clone(),this.shadow=A.shadow.clone(),this}}const JbA=new os,K1=new _e,fz=new _e;class SSe extends pz{constructor(){super(new sE(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Io(4,2),this._viewportCount=6,this._viewports=[new ug(2,1,1,1),new ug(0,1,1,1),new ug(3,1,1,1),new ug(1,1,1,1),new ug(3,0,1,1),new ug(1,0,1,1)],this._cubeDirections=[new _e(1,0,0),new _e(-1,0,0),new _e(0,0,1),new _e(0,0,-1),new _e(0,1,0),new _e(0,-1,0)],this._cubeUps=[new _e(0,1,0),new _e(0,1,0),new _e(0,1,0),new _e(0,1,0),new _e(0,0,1),new _e(0,0,-1)]}updateMatrices(A,e=0){const i=this.camera,o=this.matrix,n=A.distance||i.far;n!==i.far&&(i.far=n,i.updateProjectionMatrix()),K1.setFromMatrixPosition(A.matrixWorld),i.position.copy(K1),fz.copy(i.position),fz.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(fz),i.updateMatrixWorld(),o.makeTranslation(-K1.x,-K1.y,-K1.z),JbA.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(JbA)}}class yz extends WK{constructor(A,e,i=0,o=2){super(A,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=o,this.shadow=new SSe}get power(){return this.intensity*4*Math.PI}set power(A){this.intensity=A/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(A,e){return super.copy(A,e),this.distance=A.distance,this.decay=A.decay,this.shadow=A.shadow.clone(),this}}class bSe extends pz{constructor(){super(new k1(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class xSe extends WK{constructor(A,e){super(A,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(dg.DEFAULT_UP),this.updateMatrix(),this.target=new dg,this.shadow=new bSe}dispose(){this.shadow.dispose()}copy(A){return super.copy(A),this.target=A.target.clone(),this.shadow=A.shadow.clone(),this}}class KbA extends WK{constructor(A,e){super(A,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class Vk{static decodeText(A){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(A);let e="";for(let i=0,o=A.length;i<o;i++)e+=String.fromCharCode(A[i]);try{return decodeURIComponent(escape(e))}catch{return e}}static extractUrlBase(A){const e=A.lastIndexOf("/");return e===-1?"./":A.slice(0,e+1)}static resolveURL(A,e){return typeof A!="string"||A===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(A)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(A)||/^data:.*,.*$/i.test(A)||/^blob:.*$/i.test(A)?A:e+A)}}class kSe extends Hg{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(A){return super.copy(A),this.instanceCount=A.instanceCount,this}toJSON(){const A=super.toJSON();return A.instanceCount=this.instanceCount,A.isInstancedBufferGeometry=!0,A}}class GSe extends iw{constructor(A){super(A),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(A){return this.options=A,this}load(A,e,i,o){A===void 0&&(A=""),this.path!==void 0&&(A=this.path+A),A=this.manager.resolveURL(A);const n=this,s=Db.get(A);if(s!==void 0){if(n.manager.itemStart(A),s.then){s.then(g=>{e&&e(g),n.manager.itemEnd(A)}).catch(g=>{o&&o(g)});return}return setTimeout(function(){e&&e(s),n.manager.itemEnd(A)},0),s}const r={};r.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",r.headers=this.requestHeader;const a=fetch(A,r).then(function(g){return g.blob()}).then(function(g){return createImageBitmap(g,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(g){return Db.add(A,g),e&&e(g),n.manager.itemEnd(A),g}).catch(function(g){o&&o(g),Db.remove(A),n.manager.itemError(A),n.manager.itemEnd(A)});Db.add(A,a),n.manager.itemStart(A)}}class FSe{constructor(A=!0){this.autoStart=A,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=TbA(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let A=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=TbA();A=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=A}return A}}function TbA(){return(typeof performance>"u"?Date:performance).now()}const mz="\\[\\]\\.:\\/",_Se=new RegExp("["+mz+"]","g"),wz="[^"+mz+"]",RSe="[^"+mz.replace("\\.","")+"]",NSe=/((?:WC+[\/:])*)/.source.replace("WC",wz),MSe=/(WCOD+)?/.source.replace("WCOD",RSe),vSe=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",wz),USe=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",wz),LSe=new RegExp("^"+NSe+MSe+vSe+USe+"$"),HSe=["material","materials","bones","map"];class YSe{constructor(A,e,i){const o=i||Ia.parseTrackName(e);this._targetGroup=A,this._bindings=A.subscribe_(e,o)}getValue(A,e){this.bind();const i=this._targetGroup.nCachedObjects_,o=this._bindings[i];o!==void 0&&o.getValue(A,e)}setValue(A,e){const i=this._bindings;for(let o=this._targetGroup.nCachedObjects_,n=i.length;o!==n;++o)i[o].setValue(A,e)}bind(){const A=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=A.length;e!==i;++e)A[e].bind()}unbind(){const A=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=A.length;e!==i;++e)A[e].unbind()}}class Ia{constructor(A,e,i){this.path=e,this.parsedPath=i||Ia.parseTrackName(e),this.node=Ia.findNode(A,this.parsedPath.nodeName),this.rootNode=A,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(A,e,i){return A&&A.isAnimationObjectGroup?new Ia.Composite(A,e,i):new Ia(A,e,i)}static sanitizeNodeName(A){return A.replace(/\s/g,"_").replace(_Se,"")}static parseTrackName(A){const e=LSe.exec(A);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+A);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},o=i.nodeName&&i.nodeName.lastIndexOf(".");if(o!==void 0&&o!==-1){const n=i.nodeName.substring(o+1);HSe.indexOf(n)!==-1&&(i.nodeName=i.nodeName.substring(0,o),i.objectName=n)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+A);return i}static findNode(A,e){if(e===void 0||e===""||e==="."||e===-1||e===A.name||e===A.uuid)return A;if(A.skeleton){const i=A.skeleton.getBoneByName(e);if(i!==void 0)return i}if(A.children){const i=function(n){for(let s=0;s<n.length;s++){const r=n[s];if(r.name===e||r.uuid===e)return r;const a=i(r.children);if(a)return a}return null},o=i(A.children);if(o)return o}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(A,e){A[e]=this.targetObject[this.propertyName]}_getValue_array(A,e){const i=this.resolvedProperty;for(let o=0,n=i.length;o!==n;++o)A[e++]=i[o]}_getValue_arrayElement(A,e){A[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(A,e){this.resolvedProperty.toArray(A,e)}_setValue_direct(A,e){this.targetObject[this.propertyName]=A[e]}_setValue_direct_setNeedsUpdate(A,e){this.targetObject[this.propertyName]=A[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(A,e){this.targetObject[this.propertyName]=A[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(A,e){const i=this.resolvedProperty;for(let o=0,n=i.length;o!==n;++o)i[o]=A[e++]}_setValue_array_setNeedsUpdate(A,e){const i=this.resolvedProperty;for(let o=0,n=i.length;o!==n;++o)i[o]=A[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(A,e){const i=this.resolvedProperty;for(let o=0,n=i.length;o!==n;++o)i[o]=A[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(A,e){this.resolvedProperty[this.propertyIndex]=A[e]}_setValue_arrayElement_setNeedsUpdate(A,e){this.resolvedProperty[this.propertyIndex]=A[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(A,e){this.resolvedProperty[this.propertyIndex]=A[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(A,e){this.resolvedProperty.fromArray(A,e)}_setValue_fromArray_setNeedsUpdate(A,e){this.resolvedProperty.fromArray(A,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(A,e){this.resolvedProperty.fromArray(A,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(A,e){this.bind(),this.getValue(A,e)}_setValue_unbound(A,e){this.bind(),this.setValue(A,e)}bind(){let A=this.node;const e=this.parsedPath,i=e.objectName,o=e.propertyName;let n=e.propertyIndex;if(A||(A=Ia.findNode(this.rootNode,e.nodeName),this.node=A),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!A){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let g=e.objectIndex;switch(i){case"materials":if(!A.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!A.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}A=A.material.materials;break;case"bones":if(!A.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}A=A.skeleton.bones;for(let I=0;I<A.length;I++)if(A[I].name===g){g=I;break}break;case"map":if("map"in A){A=A.map;break}if(!A.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!A.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}A=A.material.map;break;default:if(A[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}A=A[i]}if(g!==void 0){if(A[g]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,A);return}A=A[g]}}const s=A[o];if(s===void 0){const g=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+g+"."+o+" but it wasn't found.",A);return}let r=this.Versioning.None;this.targetObject=A,A.needsUpdate!==void 0?r=this.Versioning.NeedsUpdate:A.matrixWorldNeedsUpdate!==void 0&&(r=this.Versioning.MatrixWorldNeedsUpdate);let a=this.BindingType.Direct;if(n!==void 0){if(o==="morphTargetInfluences"){if(!A.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!A.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}A.morphTargetDictionary[n]!==void 0&&(n=A.morphTargetDictionary[n])}a=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=n}else s.fromArray!==void 0&&s.toArray!==void 0?(a=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(a=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=o;this.getValue=this.GetterByBindingType[a],this.setValue=this.SetterByBindingTypeAndVersioning[a][r]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Ia.Composite=YSe,Ia.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Ia.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Ia.prototype.GetterByBindingType=[Ia.prototype._getValue_direct,Ia.prototype._getValue_array,Ia.prototype._getValue_arrayElement,Ia.prototype._getValue_toArray],Ia.prototype.SetterByBindingTypeAndVersioning=[[Ia.prototype._setValue_direct,Ia.prototype._setValue_direct_setNeedsUpdate,Ia.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ia.prototype._setValue_array,Ia.prototype._setValue_array_setNeedsUpdate,Ia.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ia.prototype._setValue_arrayElement,Ia.prototype._setValue_arrayElement_setNeedsUpdate,Ia.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ia.prototype._setValue_fromArray,Ia.prototype._setValue_fromArray_setNeedsUpdate,Ia.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Dz{constructor(A){this.value=A}clone(){return new Dz(this.value.clone===void 0?this.value:this.value.clone())}}const qbA=new os;class JSe{constructor(A,e,i=0,o=1/0){this.ray=new N_(A,e),this.near=i,this.far=o,this.camera=null,this.layers=new Mj,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(A,e){this.ray.set(A,e)}setFromCamera(A,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(A.x,A.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(A.x,A.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(A){return qbA.identity().extractRotation(A.matrixWorld),this.ray.origin.setFromMatrixPosition(A.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(qbA),this}intersectObject(A,e=!0,i=[]){return Sz(A,this,i,e),i.sort(PbA),i}intersectObjects(A,e=!0,i=[]){for(let o=0,n=A.length;o<n;o++)Sz(A[o],this,i,e);return i.sort(PbA),i}}function PbA(t,A){return t.distance-A.distance}function Sz(t,A,e,i){let o=!0;if(t.layers.test(A.layers)&&t.raycast(A,e)===!1&&(o=!1),o===!0&&i===!0){const n=t.children;for(let s=0,r=n.length;s<r;s++)Sz(n[s],A,e,!0)}}class ObA{constructor(A=1,e=0,i=0){return this.radius=A,this.phi=e,this.theta=i,this}set(A,e,i){return this.radius=A,this.phi=e,this.theta=i,this}copy(A){return this.radius=A.radius,this.phi=A.phi,this.theta=A.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(A){return this.setFromCartesianCoords(A.x,A.y,A.z)}setFromCartesianCoords(A,e,i){return this.radius=Math.sqrt(A*A+e*e+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(A,i),this.phi=Math.acos(ah(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:VJ}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=VJ);var ca;(function(t){t.assertEqual=o=>{};function A(o){}t.assertIs=A;function e(o){throw new Error}t.assertNever=e,t.arrayToEnum=o=>{const n={};for(const s of o)n[s]=s;return n},t.getValidEnumValues=o=>{const n=t.objectKeys(o).filter(r=>typeof o[o[r]]!="number"),s={};for(const r of n)s[r]=o[r];return t.objectValues(s)},t.objectValues=o=>t.objectKeys(o).map(function(n){return o[n]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{const n=[];for(const s in o)Object.prototype.hasOwnProperty.call(o,s)&&n.push(s);return n},t.find=(o,n)=>{for(const s of o)if(n(s))return s},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function i(o,n=" | "){return o.map(s=>typeof s=="string"?`'${s}'`:s).join(n)}t.joinValues=i,t.jsonStringifyReplacer=(o,n)=>typeof n=="bigint"?n.toString():n})(ca||(ca={}));var WbA;(function(t){t.mergeShapes=(A,e)=>({...A,...e})})(WbA||(WbA={}));const Oi=ca.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Sb=t=>{switch(typeof t){case"undefined":return Oi.undefined;case"string":return Oi.string;case"number":return Number.isNaN(t)?Oi.nan:Oi.number;case"boolean":return Oi.boolean;case"function":return Oi.function;case"bigint":return Oi.bigint;case"symbol":return Oi.symbol;case"object":return Array.isArray(t)?Oi.array:t===null?Oi.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Oi.promise:typeof Map<"u"&&t instanceof Map?Oi.map:typeof Set<"u"&&t instanceof Set?Oi.set:typeof Date<"u"&&t instanceof Date?Oi.date:Oi.object;default:return Oi.unknown}},Wt=ca.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class j0 extends Error{get errors(){return this.issues}constructor(A){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=A}format(A){const e=A||function(n){return n.message},i={_errors:[]},o=n=>{for(const s of n.issues)if(s.code==="invalid_union")s.unionErrors.map(o);else if(s.code==="invalid_return_type")o(s.returnTypeError);else if(s.code==="invalid_arguments")o(s.argumentsError);else if(s.path.length===0)i._errors.push(e(s));else{let r=i,a=0;for(;a<s.path.length;){const g=s.path[a];a===s.path.length-1?(r[g]=r[g]||{_errors:[]},r[g]._errors.push(e(s))):r[g]=r[g]||{_errors:[]},r=r[g],a++}}};return o(this),i}static assert(A){if(!(A instanceof j0))throw new Error(`Not a ZodError: ${A}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ca.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(A=e=>e.message){const e={},i=[];for(const o of this.issues)if(o.path.length>0){const n=o.path[0];e[n]=e[n]||[],e[n].push(A(o))}else i.push(A(o));return{formErrors:i,fieldErrors:e}}get formErrors(){return this.flatten()}}j0.create=t=>new j0(t);const T1=(t,A)=>{let e;switch(t.code){case Wt.invalid_type:t.received===Oi.undefined?e="Required":e=`Expected ${t.expected}, received ${t.received}`;break;case Wt.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(t.expected,ca.jsonStringifyReplacer)}`;break;case Wt.unrecognized_keys:e=`Unrecognized key(s) in object: ${ca.joinValues(t.keys,", ")}`;break;case Wt.invalid_union:e="Invalid input";break;case Wt.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${ca.joinValues(t.options)}`;break;case Wt.invalid_enum_value:e=`Invalid enum value. Expected ${ca.joinValues(t.options)}, received '${t.received}'`;break;case Wt.invalid_arguments:e="Invalid function arguments";break;case Wt.invalid_return_type:e="Invalid function return type";break;case Wt.invalid_date:e="Invalid date";break;case Wt.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(e=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?e=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?e=`Invalid input: must end with "${t.validation.endsWith}"`:ca.assertNever(t.validation):t.validation!=="regex"?e=`Invalid ${t.validation}`:e="Invalid";break;case Wt.too_small:t.type==="array"?e=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?e=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?e=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?e=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?e=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:e="Invalid input";break;case Wt.too_big:t.type==="array"?e=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?e=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?e=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?e=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?e=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:e="Invalid input";break;case Wt.custom:e="Invalid input";break;case Wt.invalid_intersection_types:e="Intersection results could not be merged";break;case Wt.not_multiple_of:e=`Number must be a multiple of ${t.multipleOf}`;break;case Wt.not_finite:e="Number must be finite";break;default:e=A.defaultError,ca.assertNever(t)}return{message:e}};let KSe=T1;function bz(){return KSe}const xz=t=>{const{data:A,path:e,errorMaps:i,issueData:o}=t,n=[...e,...o.path||[]],s={...o,path:n};if(o.message!==void 0)return{...o,path:n,message:o.message};let r="";const a=i.filter(g=>!!g).slice().reverse();for(const g of a)r=g(s,{data:A,defaultError:r}).message;return{...o,path:n,message:r}};function bi(t,A){const e=bz(),i=xz({issueData:A,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,e,e===T1?void 0:T1].filter(o=>!!o)});t.common.issues.push(i)}class fd{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(A,e){const i=[];for(const o of e){if(o.status==="aborted")return Qn;o.status==="dirty"&&A.dirty(),i.push(o.value)}return{status:A.value,value:i}}static async mergeObjectAsync(A,e){const i=[];for(const o of e){const n=await o.key,s=await o.value;i.push({key:n,value:s})}return fd.mergeObjectSync(A,i)}static mergeObjectSync(A,e){const i={};for(const o of e){const{key:n,value:s}=o;if(n.status==="aborted"||s.status==="aborted")return Qn;n.status==="dirty"&&A.dirty(),s.status==="dirty"&&A.dirty(),n.value!=="__proto__"&&(typeof s.value<"u"||o.alwaysSet)&&(i[n.value]=s.value)}return{status:A.value,value:i}}}const Qn=Object.freeze({status:"aborted"}),q1=t=>({status:"dirty",value:t}),vp=t=>({status:"valid",value:t}),ZbA=t=>t.status==="aborted",VbA=t=>t.status==="dirty",oR=t=>t.status==="valid",ZK=t=>typeof Promise<"u"&&t instanceof Promise;var wo;(function(t){t.errToObj=A=>typeof A=="string"?{message:A}:A||{},t.toString=A=>typeof A=="string"?A:A?.message})(wo||(wo={}));class ow{constructor(A,e,i,o){this._cachedPath=[],this.parent=A,this.data=e,this._path=i,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const jbA=(t,A)=>{if(oR(A))return{success:!0,data:A.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new j0(t.common.issues);return this._error=e,this._error}}};function Ds(t){if(!t)return{};const{errorMap:A,invalid_type_error:e,required_error:i,description:o}=t;if(A&&(e||i))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return A?{errorMap:A,description:o}:{errorMap:(s,r)=>{const{message:a}=t;return s.code==="invalid_enum_value"?{message:a??r.defaultError}:typeof r.data>"u"?{message:a??i??r.defaultError}:s.code!=="invalid_type"?{message:r.defaultError}:{message:a??e??r.defaultError}},description:o}}class Cr{get description(){return this._def.description}_getType(A){return Sb(A.data)}_getOrReturnCtx(A,e){return e||{common:A.parent.common,data:A.data,parsedType:Sb(A.data),schemaErrorMap:this._def.errorMap,path:A.path,parent:A.parent}}_processInputParams(A){return{status:new fd,ctx:{common:A.parent.common,data:A.data,parsedType:Sb(A.data),schemaErrorMap:this._def.errorMap,path:A.path,parent:A.parent}}}_parseSync(A){const e=this._parse(A);if(ZK(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(A){const e=this._parse(A);return Promise.resolve(e)}parse(A,e){const i=this.safeParse(A,e);if(i.success)return i.data;throw i.error}safeParse(A,e){const i={common:{issues:[],async:e?.async??!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:Sb(A)},o=this._parseSync({data:A,path:i.path,parent:i});return jbA(i,o)}"~validate"(A){const e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:Sb(A)};if(!this["~standard"].async)try{const i=this._parseSync({data:A,path:[],parent:e});return oR(i)?{value:i.value}:{issues:e.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:A,path:[],parent:e}).then(i=>oR(i)?{value:i.value}:{issues:e.common.issues})}async parseAsync(A,e){const i=await this.safeParseAsync(A,e);if(i.success)return i.data;throw i.error}async safeParseAsync(A,e){const i={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:A,parsedType:Sb(A)},o=this._parse({data:A,path:i.path,parent:i}),n=await(ZK(o)?o:Promise.resolve(o));return jbA(i,n)}refine(A,e){const i=o=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(o):e;return this._refinement((o,n)=>{const s=A(o),r=()=>n.addIssue({code:Wt.custom,...i(o)});return typeof Promise<"u"&&s instanceof Promise?s.then(a=>a?!0:(r(),!1)):s?!0:(r(),!1)})}refinement(A,e){return this._refinement((i,o)=>A(i)?!0:(o.addIssue(typeof e=="function"?e(i,o):e),!1))}_refinement(A){return new zk({schema:this,typeName:Fn.ZodEffects,effect:{type:"refinement",refinement:A}})}superRefine(A){return this._refinement(A)}constructor(A){this.spa=this.safeParseAsync,this._def=A,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return LD.create(this,this._def)}nullable(){return Xk.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return nw.create(this)}promise(){return V1.create(this,this._def)}or(A){return zK.create([this,A],this._def)}and(A){return XK.create(this,A,this._def)}transform(A){return new zk({...Ds(this._def),schema:this,typeName:Fn.ZodEffects,effect:{type:"transform",transform:A}})}default(A){const e=typeof A=="function"?A:()=>A;return new eT({...Ds(this._def),innerType:this,defaultValue:e,typeName:Fn.ZodDefault})}brand(){return new oxA({typeName:Fn.ZodBranded,type:this,...Ds(this._def)})}catch(A){const e=typeof A=="function"?A:()=>A;return new tT({...Ds(this._def),innerType:this,catchValue:e,typeName:Fn.ZodCatch})}describe(A){const e=this.constructor;return new e({...this._def,description:A})}pipe(A){return vz.create(this,A)}readonly(){return iT.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const TSe=/^c[^\s-]{8,}$/i,qSe=/^[0-9a-z]+$/,PSe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,OSe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,WSe=/^[a-z0-9_-]{21}$/i,ZSe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,VSe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,jSe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zSe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let kz;const XSe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,$Se=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Abe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ebe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tbe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ibe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zbA="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",obe=new RegExp(`^${zbA}$`);function XbA(t){let A="[0-5]\\d";t.precision?A=`${A}\\.\\d{${t.precision}}`:t.precision==null&&(A=`${A}(\\.\\d+)?`);const e=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${A})${e}`}function nbe(t){return new RegExp(`^${XbA(t)}$`)}function sbe(t){let A=`${zbA}T${XbA(t)}`;const e=[];return e.push(t.local?"Z?":"Z"),t.offset&&e.push("([+-]\\d{2}:?\\d{2})"),A=`${A}(${e.join("|")})`,new RegExp(`^${A}$`)}function rbe(t,A){return!!((A==="v4"||!A)&&XSe.test(t)||(A==="v6"||!A)&&Abe.test(t))}function abe(t,A){if(!ZSe.test(t))return!1;try{const[e]=t.split(".");if(!e)return!1;const i=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),o=JSON.parse(atob(i));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||A&&o.alg!==A)}catch{return!1}}function gbe(t,A){return!!((A==="v4"||!A)&&$Se.test(t)||(A==="v6"||!A)&&ebe.test(t))}class MD extends Cr{_parse(A){if(this._def.coerce&&(A.data=String(A.data)),this._getType(A)!==Oi.string){const n=this._getOrReturnCtx(A);return bi(n,{code:Wt.invalid_type,expected:Oi.string,received:n.parsedType}),Qn}const i=new fd;let o;for(const n of this._def.checks)if(n.kind==="min")A.data.length<n.value&&(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="max")A.data.length>n.value&&(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="length"){const s=A.data.length>n.value,r=A.data.length<n.value;(s||r)&&(o=this._getOrReturnCtx(A,o),s?bi(o,{code:Wt.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):r&&bi(o,{code:Wt.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),i.dirty())}else if(n.kind==="email")jSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"email",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="emoji")kz||(kz=new RegExp(zSe,"u")),kz.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"emoji",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="uuid")OSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"uuid",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="nanoid")WSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"nanoid",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid")TSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"cuid",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid2")qSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"cuid2",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="ulid")PSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"ulid",code:Wt.invalid_string,message:n.message}),i.dirty());else if(n.kind==="url")try{new URL(A.data)}catch{o=this._getOrReturnCtx(A,o),bi(o,{validation:"url",code:Wt.invalid_string,message:n.message}),i.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"regex",code:Wt.invalid_string,message:n.message}),i.dirty())):n.kind==="trim"?A.data=A.data.trim():n.kind==="includes"?A.data.includes(n.value,n.position)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),i.dirty()):n.kind==="toLowerCase"?A.data=A.data.toLowerCase():n.kind==="toUpperCase"?A.data=A.data.toUpperCase():n.kind==="startsWith"?A.data.startsWith(n.value)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:{startsWith:n.value},message:n.message}),i.dirty()):n.kind==="endsWith"?A.data.endsWith(n.value)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:{endsWith:n.value},message:n.message}),i.dirty()):n.kind==="datetime"?sbe(n).test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:"datetime",message:n.message}),i.dirty()):n.kind==="date"?obe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:"date",message:n.message}),i.dirty()):n.kind==="time"?nbe(n).test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.invalid_string,validation:"time",message:n.message}),i.dirty()):n.kind==="duration"?VSe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"duration",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="ip"?rbe(A.data,n.version)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"ip",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="jwt"?abe(A.data,n.alg)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"jwt",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="cidr"?gbe(A.data,n.version)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"cidr",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="base64"?tbe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"base64",code:Wt.invalid_string,message:n.message}),i.dirty()):n.kind==="base64url"?ibe.test(A.data)||(o=this._getOrReturnCtx(A,o),bi(o,{validation:"base64url",code:Wt.invalid_string,message:n.message}),i.dirty()):ca.assertNever(n);return{status:i.value,value:A.data}}_regex(A,e,i){return this.refinement(o=>A.test(o),{validation:e,code:Wt.invalid_string,...wo.errToObj(i)})}_addCheck(A){return new MD({...this._def,checks:[...this._def.checks,A]})}email(A){return this._addCheck({kind:"email",...wo.errToObj(A)})}url(A){return this._addCheck({kind:"url",...wo.errToObj(A)})}emoji(A){return this._addCheck({kind:"emoji",...wo.errToObj(A)})}uuid(A){return this._addCheck({kind:"uuid",...wo.errToObj(A)})}nanoid(A){return this._addCheck({kind:"nanoid",...wo.errToObj(A)})}cuid(A){return this._addCheck({kind:"cuid",...wo.errToObj(A)})}cuid2(A){return this._addCheck({kind:"cuid2",...wo.errToObj(A)})}ulid(A){return this._addCheck({kind:"ulid",...wo.errToObj(A)})}base64(A){return this._addCheck({kind:"base64",...wo.errToObj(A)})}base64url(A){return this._addCheck({kind:"base64url",...wo.errToObj(A)})}jwt(A){return this._addCheck({kind:"jwt",...wo.errToObj(A)})}ip(A){return this._addCheck({kind:"ip",...wo.errToObj(A)})}cidr(A){return this._addCheck({kind:"cidr",...wo.errToObj(A)})}datetime(A){return typeof A=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:A}):this._addCheck({kind:"datetime",precision:typeof A?.precision>"u"?null:A?.precision,offset:A?.offset??!1,local:A?.local??!1,...wo.errToObj(A?.message)})}date(A){return this._addCheck({kind:"date",message:A})}time(A){return typeof A=="string"?this._addCheck({kind:"time",precision:null,message:A}):this._addCheck({kind:"time",precision:typeof A?.precision>"u"?null:A?.precision,...wo.errToObj(A?.message)})}duration(A){return this._addCheck({kind:"duration",...wo.errToObj(A)})}regex(A,e){return this._addCheck({kind:"regex",regex:A,...wo.errToObj(e)})}includes(A,e){return this._addCheck({kind:"includes",value:A,position:e?.position,...wo.errToObj(e?.message)})}startsWith(A,e){return this._addCheck({kind:"startsWith",value:A,...wo.errToObj(e)})}endsWith(A,e){return this._addCheck({kind:"endsWith",value:A,...wo.errToObj(e)})}min(A,e){return this._addCheck({kind:"min",value:A,...wo.errToObj(e)})}max(A,e){return this._addCheck({kind:"max",value:A,...wo.errToObj(e)})}length(A,e){return this._addCheck({kind:"length",value:A,...wo.errToObj(e)})}nonempty(A){return this.min(1,wo.errToObj(A))}trim(){return new MD({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new MD({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new MD({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(A=>A.kind==="datetime")}get isDate(){return!!this._def.checks.find(A=>A.kind==="date")}get isTime(){return!!this._def.checks.find(A=>A.kind==="time")}get isDuration(){return!!this._def.checks.find(A=>A.kind==="duration")}get isEmail(){return!!this._def.checks.find(A=>A.kind==="email")}get isURL(){return!!this._def.checks.find(A=>A.kind==="url")}get isEmoji(){return!!this._def.checks.find(A=>A.kind==="emoji")}get isUUID(){return!!this._def.checks.find(A=>A.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(A=>A.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(A=>A.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(A=>A.kind==="cuid2")}get isULID(){return!!this._def.checks.find(A=>A.kind==="ulid")}get isIP(){return!!this._def.checks.find(A=>A.kind==="ip")}get isCIDR(){return!!this._def.checks.find(A=>A.kind==="cidr")}get isBase64(){return!!this._def.checks.find(A=>A.kind==="base64")}get isBase64url(){return!!this._def.checks.find(A=>A.kind==="base64url")}get minLength(){let A=null;for(const e of this._def.checks)e.kind==="min"&&(A===null||e.value>A)&&(A=e.value);return A}get maxLength(){let A=null;for(const e of this._def.checks)e.kind==="max"&&(A===null||e.value<A)&&(A=e.value);return A}}MD.create=t=>new MD({checks:[],typeName:Fn.ZodString,coerce:t?.coerce??!1,...Ds(t)});function Ibe(t,A){const e=(t.toString().split(".")[1]||"").length,i=(A.toString().split(".")[1]||"").length,o=e>i?e:i,n=Number.parseInt(t.toFixed(o).replace(".","")),s=Number.parseInt(A.toFixed(o).replace(".",""));return n%s/10**o}class nR extends Cr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(A){if(this._def.coerce&&(A.data=Number(A.data)),this._getType(A)!==Oi.number){const n=this._getOrReturnCtx(A);return bi(n,{code:Wt.invalid_type,expected:Oi.number,received:n.parsedType}),Qn}let i;const o=new fd;for(const n of this._def.checks)n.kind==="int"?ca.isInteger(A.data)||(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.invalid_type,expected:"integer",received:"float",message:n.message}),o.dirty()):n.kind==="min"?(n.inclusive?A.data<n.value:A.data<=n.value)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),o.dirty()):n.kind==="max"?(n.inclusive?A.data>n.value:A.data>=n.value)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),o.dirty()):n.kind==="multipleOf"?Ibe(A.data,n.value)!==0&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.not_multiple_of,multipleOf:n.value,message:n.message}),o.dirty()):n.kind==="finite"?Number.isFinite(A.data)||(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.not_finite,message:n.message}),o.dirty()):ca.assertNever(n);return{status:o.value,value:A.data}}gte(A,e){return this.setLimit("min",A,!0,wo.toString(e))}gt(A,e){return this.setLimit("min",A,!1,wo.toString(e))}lte(A,e){return this.setLimit("max",A,!0,wo.toString(e))}lt(A,e){return this.setLimit("max",A,!1,wo.toString(e))}setLimit(A,e,i,o){return new nR({...this._def,checks:[...this._def.checks,{kind:A,value:e,inclusive:i,message:wo.toString(o)}]})}_addCheck(A){return new nR({...this._def,checks:[...this._def.checks,A]})}int(A){return this._addCheck({kind:"int",message:wo.toString(A)})}positive(A){return this._addCheck({kind:"min",value:0,inclusive:!1,message:wo.toString(A)})}negative(A){return this._addCheck({kind:"max",value:0,inclusive:!1,message:wo.toString(A)})}nonpositive(A){return this._addCheck({kind:"max",value:0,inclusive:!0,message:wo.toString(A)})}nonnegative(A){return this._addCheck({kind:"min",value:0,inclusive:!0,message:wo.toString(A)})}multipleOf(A,e){return this._addCheck({kind:"multipleOf",value:A,message:wo.toString(e)})}finite(A){return this._addCheck({kind:"finite",message:wo.toString(A)})}safe(A){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:wo.toString(A)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:wo.toString(A)})}get minValue(){let A=null;for(const e of this._def.checks)e.kind==="min"&&(A===null||e.value>A)&&(A=e.value);return A}get maxValue(){let A=null;for(const e of this._def.checks)e.kind==="max"&&(A===null||e.value<A)&&(A=e.value);return A}get isInt(){return!!this._def.checks.find(A=>A.kind==="int"||A.kind==="multipleOf"&&ca.isInteger(A.value))}get isFinite(){let A=null,e=null;for(const i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(e===null||i.value>e)&&(e=i.value):i.kind==="max"&&(A===null||i.value<A)&&(A=i.value)}return Number.isFinite(e)&&Number.isFinite(A)}}nR.create=t=>new nR({checks:[],typeName:Fn.ZodNumber,coerce:t?.coerce||!1,...Ds(t)});class P1 extends Cr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(A){if(this._def.coerce)try{A.data=BigInt(A.data)}catch{return this._getInvalidInput(A)}if(this._getType(A)!==Oi.bigint)return this._getInvalidInput(A);let i;const o=new fd;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?A.data<n.value:A.data<=n.value)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),o.dirty()):n.kind==="max"?(n.inclusive?A.data>n.value:A.data>=n.value)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),o.dirty()):n.kind==="multipleOf"?A.data%n.value!==BigInt(0)&&(i=this._getOrReturnCtx(A,i),bi(i,{code:Wt.not_multiple_of,multipleOf:n.value,message:n.message}),o.dirty()):ca.assertNever(n);return{status:o.value,value:A.data}}_getInvalidInput(A){const e=this._getOrReturnCtx(A);return bi(e,{code:Wt.invalid_type,expected:Oi.bigint,received:e.parsedType}),Qn}gte(A,e){return this.setLimit("min",A,!0,wo.toString(e))}gt(A,e){return this.setLimit("min",A,!1,wo.toString(e))}lte(A,e){return this.setLimit("max",A,!0,wo.toString(e))}lt(A,e){return this.setLimit("max",A,!1,wo.toString(e))}setLimit(A,e,i,o){return new P1({...this._def,checks:[...this._def.checks,{kind:A,value:e,inclusive:i,message:wo.toString(o)}]})}_addCheck(A){return new P1({...this._def,checks:[...this._def.checks,A]})}positive(A){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:wo.toString(A)})}negative(A){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:wo.toString(A)})}nonpositive(A){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:wo.toString(A)})}nonnegative(A){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:wo.toString(A)})}multipleOf(A,e){return this._addCheck({kind:"multipleOf",value:A,message:wo.toString(e)})}get minValue(){let A=null;for(const e of this._def.checks)e.kind==="min"&&(A===null||e.value>A)&&(A=e.value);return A}get maxValue(){let A=null;for(const e of this._def.checks)e.kind==="max"&&(A===null||e.value<A)&&(A=e.value);return A}}P1.create=t=>new P1({checks:[],typeName:Fn.ZodBigInt,coerce:t?.coerce??!1,...Ds(t)});class Gz extends Cr{_parse(A){if(this._def.coerce&&(A.data=!!A.data),this._getType(A)!==Oi.boolean){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.boolean,received:i.parsedType}),Qn}return vp(A.data)}}Gz.create=t=>new Gz({typeName:Fn.ZodBoolean,coerce:t?.coerce||!1,...Ds(t)});class VK extends Cr{_parse(A){if(this._def.coerce&&(A.data=new Date(A.data)),this._getType(A)!==Oi.date){const n=this._getOrReturnCtx(A);return bi(n,{code:Wt.invalid_type,expected:Oi.date,received:n.parsedType}),Qn}if(Number.isNaN(A.data.getTime())){const n=this._getOrReturnCtx(A);return bi(n,{code:Wt.invalid_date}),Qn}const i=new fd;let o;for(const n of this._def.checks)n.kind==="min"?A.data.getTime()<n.value&&(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),i.dirty()):n.kind==="max"?A.data.getTime()>n.value&&(o=this._getOrReturnCtx(A,o),bi(o,{code:Wt.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),i.dirty()):ca.assertNever(n);return{status:i.value,value:new Date(A.data.getTime())}}_addCheck(A){return new VK({...this._def,checks:[...this._def.checks,A]})}min(A,e){return this._addCheck({kind:"min",value:A.getTime(),message:wo.toString(e)})}max(A,e){return this._addCheck({kind:"max",value:A.getTime(),message:wo.toString(e)})}get minDate(){let A=null;for(const e of this._def.checks)e.kind==="min"&&(A===null||e.value>A)&&(A=e.value);return A!=null?new Date(A):null}get maxDate(){let A=null;for(const e of this._def.checks)e.kind==="max"&&(A===null||e.value<A)&&(A=e.value);return A!=null?new Date(A):null}}VK.create=t=>new VK({checks:[],coerce:t?.coerce||!1,typeName:Fn.ZodDate,...Ds(t)});class $bA extends Cr{_parse(A){if(this._getType(A)!==Oi.symbol){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.symbol,received:i.parsedType}),Qn}return vp(A.data)}}$bA.create=t=>new $bA({typeName:Fn.ZodSymbol,...Ds(t)});class Fz extends Cr{_parse(A){if(this._getType(A)!==Oi.undefined){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.undefined,received:i.parsedType}),Qn}return vp(A.data)}}Fz.create=t=>new Fz({typeName:Fn.ZodUndefined,...Ds(t)});class jK extends Cr{_parse(A){if(this._getType(A)!==Oi.null){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.null,received:i.parsedType}),Qn}return vp(A.data)}}jK.create=t=>new jK({typeName:Fn.ZodNull,...Ds(t)});class O1 extends Cr{constructor(){super(...arguments),this._any=!0}_parse(A){return vp(A.data)}}O1.create=t=>new O1({typeName:Fn.ZodAny,...Ds(t)});class sR extends Cr{constructor(){super(...arguments),this._unknown=!0}_parse(A){return vp(A.data)}}sR.create=t=>new sR({typeName:Fn.ZodUnknown,...Ds(t)});class bb extends Cr{_parse(A){const e=this._getOrReturnCtx(A);return bi(e,{code:Wt.invalid_type,expected:Oi.never,received:e.parsedType}),Qn}}bb.create=t=>new bb({typeName:Fn.ZodNever,...Ds(t)});class AxA extends Cr{_parse(A){if(this._getType(A)!==Oi.undefined){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.void,received:i.parsedType}),Qn}return vp(A.data)}}AxA.create=t=>new AxA({typeName:Fn.ZodVoid,...Ds(t)});class nw extends Cr{_parse(A){const{ctx:e,status:i}=this._processInputParams(A),o=this._def;if(e.parsedType!==Oi.array)return bi(e,{code:Wt.invalid_type,expected:Oi.array,received:e.parsedType}),Qn;if(o.exactLength!==null){const s=e.data.length>o.exactLength.value,r=e.data.length<o.exactLength.value;(s||r)&&(bi(e,{code:s?Wt.too_big:Wt.too_small,minimum:r?o.exactLength.value:void 0,maximum:s?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),i.dirty())}if(o.minLength!==null&&e.data.length<o.minLength.value&&(bi(e,{code:Wt.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),i.dirty()),o.maxLength!==null&&e.data.length>o.maxLength.value&&(bi(e,{code:Wt.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),i.dirty()),e.common.async)return Promise.all([...e.data].map((s,r)=>o.type._parseAsync(new ow(e,s,e.path,r)))).then(s=>fd.mergeArray(i,s));const n=[...e.data].map((s,r)=>o.type._parseSync(new ow(e,s,e.path,r)));return fd.mergeArray(i,n)}get element(){return this._def.type}min(A,e){return new nw({...this._def,minLength:{value:A,message:wo.toString(e)}})}max(A,e){return new nw({...this._def,maxLength:{value:A,message:wo.toString(e)}})}length(A,e){return new nw({...this._def,exactLength:{value:A,message:wo.toString(e)}})}nonempty(A){return this.min(1,A)}}nw.create=(t,A)=>new nw({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Fn.ZodArray,...Ds(A)});function rR(t){if(t instanceof Sl){const A={};for(const e in t.shape){const i=t.shape[e];A[e]=LD.create(rR(i))}return new Sl({...t._def,shape:()=>A})}else return t instanceof nw?new nw({...t._def,type:rR(t.element)}):t instanceof LD?LD.create(rR(t.unwrap())):t instanceof Xk?Xk.create(rR(t.unwrap())):t instanceof UD?UD.create(t.items.map(A=>rR(A))):t}class Sl extends Cr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const A=this._def.shape(),e=ca.objectKeys(A);return this._cached={shape:A,keys:e},this._cached}_parse(A){if(this._getType(A)!==Oi.object){const g=this._getOrReturnCtx(A);return bi(g,{code:Wt.invalid_type,expected:Oi.object,received:g.parsedType}),Qn}const{status:i,ctx:o}=this._processInputParams(A),{shape:n,keys:s}=this._getCached(),r=[];if(!(this._def.catchall instanceof bb&&this._def.unknownKeys==="strip"))for(const g in o.data)s.includes(g)||r.push(g);const a=[];for(const g of s){const I=n[g],c=o.data[g];a.push({key:{status:"valid",value:g},value:I._parse(new ow(o,c,o.path,g)),alwaysSet:g in o.data})}if(this._def.catchall instanceof bb){const g=this._def.unknownKeys;if(g==="passthrough")for(const I of r)a.push({key:{status:"valid",value:I},value:{status:"valid",value:o.data[I]}});else if(g==="strict")r.length>0&&(bi(o,{code:Wt.unrecognized_keys,keys:r}),i.dirty());else if(g!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const g=this._def.catchall;for(const I of r){const c=o.data[I];a.push({key:{status:"valid",value:I},value:g._parse(new ow(o,c,o.path,I)),alwaysSet:I in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const g=[];for(const I of a){const c=await I.key,B=await I.value;g.push({key:c,value:B,alwaysSet:I.alwaysSet})}return g}).then(g=>fd.mergeObjectSync(i,g)):fd.mergeObjectSync(i,a)}get shape(){return this._def.shape()}strict(A){return wo.errToObj,new Sl({...this._def,unknownKeys:"strict",...A!==void 0?{errorMap:(e,i)=>{const o=this._def.errorMap?.(e,i).message??i.defaultError;return e.code==="unrecognized_keys"?{message:wo.errToObj(A).message??o}:{message:o}}}:{}})}strip(){return new Sl({...this._def,unknownKeys:"strip"})}passthrough(){return new Sl({...this._def,unknownKeys:"passthrough"})}extend(A){return new Sl({...this._def,shape:()=>({...this._def.shape(),...A})})}merge(A){return new Sl({unknownKeys:A._def.unknownKeys,catchall:A._def.catchall,shape:()=>({...this._def.shape(),...A._def.shape()}),typeName:Fn.ZodObject})}setKey(A,e){return this.augment({[A]:e})}catchall(A){return new Sl({...this._def,catchall:A})}pick(A){const e={};for(const i of ca.objectKeys(A))A[i]&&this.shape[i]&&(e[i]=this.shape[i]);return new Sl({...this._def,shape:()=>e})}omit(A){const e={};for(const i of ca.objectKeys(this.shape))A[i]||(e[i]=this.shape[i]);return new Sl({...this._def,shape:()=>e})}deepPartial(){return rR(this)}partial(A){const e={};for(const i of ca.objectKeys(this.shape)){const o=this.shape[i];A&&!A[i]?e[i]=o:e[i]=o.optional()}return new Sl({...this._def,shape:()=>e})}required(A){const e={};for(const i of ca.objectKeys(this.shape))if(A&&!A[i])e[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof LD;)n=n._def.innerType;e[i]=n}return new Sl({...this._def,shape:()=>e})}keyof(){return txA(ca.objectKeys(this.shape))}}Sl.create=(t,A)=>new Sl({shape:()=>t,unknownKeys:"strip",catchall:bb.create(),typeName:Fn.ZodObject,...Ds(A)}),Sl.strictCreate=(t,A)=>new Sl({shape:()=>t,unknownKeys:"strict",catchall:bb.create(),typeName:Fn.ZodObject,...Ds(A)}),Sl.lazycreate=(t,A)=>new Sl({shape:t,unknownKeys:"strip",catchall:bb.create(),typeName:Fn.ZodObject,...Ds(A)});class zK extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A),i=this._def.options;function o(n){for(const r of n)if(r.result.status==="valid")return r.result;for(const r of n)if(r.result.status==="dirty")return e.common.issues.push(...r.ctx.common.issues),r.result;const s=n.map(r=>new j0(r.ctx.common.issues));return bi(e,{code:Wt.invalid_union,unionErrors:s}),Qn}if(e.common.async)return Promise.all(i.map(async n=>{const s={...e,common:{...e.common,issues:[]},parent:null};return{result:await n._parseAsync({data:e.data,path:e.path,parent:s}),ctx:s}})).then(o);{let n;const s=[];for(const a of i){const g={...e,common:{...e.common,issues:[]},parent:null},I=a._parseSync({data:e.data,path:e.path,parent:g});if(I.status==="valid")return I;I.status==="dirty"&&!n&&(n={result:I,ctx:g}),g.common.issues.length&&s.push(g.common.issues)}if(n)return e.common.issues.push(...n.ctx.common.issues),n.result;const r=s.map(a=>new j0(a));return bi(e,{code:Wt.invalid_union,unionErrors:r}),Qn}}get options(){return this._def.options}}zK.create=(t,A)=>new zK({options:t,typeName:Fn.ZodUnion,...Ds(A)});const vD=t=>t instanceof Nz?vD(t.schema):t instanceof zk?vD(t.innerType()):t instanceof AT?[t.value]:t instanceof jk?t.options:t instanceof Mz?ca.objectValues(t.enum):t instanceof eT?vD(t._def.innerType):t instanceof Fz?[void 0]:t instanceof jK?[null]:t instanceof LD?[void 0,...vD(t.unwrap())]:t instanceof Xk?[null,...vD(t.unwrap())]:t instanceof oxA||t instanceof iT?vD(t.unwrap()):t instanceof tT?vD(t._def.innerType):[];class _z extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A);if(e.parsedType!==Oi.object)return bi(e,{code:Wt.invalid_type,expected:Oi.object,received:e.parsedType}),Qn;const i=this.discriminator,o=e.data[i],n=this.optionsMap.get(o);return n?e.common.async?n._parseAsync({data:e.data,path:e.path,parent:e}):n._parseSync({data:e.data,path:e.path,parent:e}):(bi(e,{code:Wt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),Qn)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(A,e,i){const o=new Map;for(const n of e){const s=vD(n.shape[A]);if(!s.length)throw new Error(`A discriminator value for key \`${A}\` could not be extracted from all schema options`);for(const r of s){if(o.has(r))throw new Error(`Discriminator property ${String(A)} has duplicate value ${String(r)}`);o.set(r,n)}}return new _z({typeName:Fn.ZodDiscriminatedUnion,discriminator:A,options:e,optionsMap:o,...Ds(i)})}}function Rz(t,A){const e=Sb(t),i=Sb(A);if(t===A)return{valid:!0,data:t};if(e===Oi.object&&i===Oi.object){const o=ca.objectKeys(A),n=ca.objectKeys(t).filter(r=>o.indexOf(r)!==-1),s={...t,...A};for(const r of n){const a=Rz(t[r],A[r]);if(!a.valid)return{valid:!1};s[r]=a.data}return{valid:!0,data:s}}else if(e===Oi.array&&i===Oi.array){if(t.length!==A.length)return{valid:!1};const o=[];for(let n=0;n<t.length;n++){const s=t[n],r=A[n],a=Rz(s,r);if(!a.valid)return{valid:!1};o.push(a.data)}return{valid:!0,data:o}}else return e===Oi.date&&i===Oi.date&&+t==+A?{valid:!0,data:t}:{valid:!1}}class XK extends Cr{_parse(A){const{status:e,ctx:i}=this._processInputParams(A),o=(n,s)=>{if(ZbA(n)||ZbA(s))return Qn;const r=Rz(n.value,s.value);return r.valid?((VbA(n)||VbA(s))&&e.dirty(),{status:e.value,value:r.data}):(bi(i,{code:Wt.invalid_intersection_types}),Qn)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([n,s])=>o(n,s)):o(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}}XK.create=(t,A,e)=>new XK({left:t,right:A,typeName:Fn.ZodIntersection,...Ds(e)});class UD extends Cr{_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.parsedType!==Oi.array)return bi(i,{code:Wt.invalid_type,expected:Oi.array,received:i.parsedType}),Qn;if(i.data.length<this._def.items.length)return bi(i,{code:Wt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Qn;!this._def.rest&&i.data.length>this._def.items.length&&(bi(i,{code:Wt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const n=[...i.data].map((s,r)=>{const a=this._def.items[r]||this._def.rest;return a?a._parse(new ow(i,s,i.path,r)):null}).filter(s=>!!s);return i.common.async?Promise.all(n).then(s=>fd.mergeArray(e,s)):fd.mergeArray(e,n)}get items(){return this._def.items}rest(A){return new UD({...this._def,rest:A})}}UD.create=(t,A)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new UD({items:t,typeName:Fn.ZodTuple,rest:null,...Ds(A)})};class $K extends Cr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.parsedType!==Oi.object)return bi(i,{code:Wt.invalid_type,expected:Oi.object,received:i.parsedType}),Qn;const o=[],n=this._def.keyType,s=this._def.valueType;for(const r in i.data)o.push({key:n._parse(new ow(i,r,i.path,r)),value:s._parse(new ow(i,i.data[r],i.path,r)),alwaysSet:r in i.data});return i.common.async?fd.mergeObjectAsync(e,o):fd.mergeObjectSync(e,o)}get element(){return this._def.valueType}static create(A,e,i){return e instanceof Cr?new $K({keyType:A,valueType:e,typeName:Fn.ZodRecord,...Ds(i)}):new $K({keyType:MD.create(),valueType:A,typeName:Fn.ZodRecord,...Ds(e)})}}class exA extends Cr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.parsedType!==Oi.map)return bi(i,{code:Wt.invalid_type,expected:Oi.map,received:i.parsedType}),Qn;const o=this._def.keyType,n=this._def.valueType,s=[...i.data.entries()].map(([r,a],g)=>({key:o._parse(new ow(i,r,i.path,[g,"key"])),value:n._parse(new ow(i,a,i.path,[g,"value"]))}));if(i.common.async){const r=new Map;return Promise.resolve().then(async()=>{for(const a of s){const g=await a.key,I=await a.value;if(g.status==="aborted"||I.status==="aborted")return Qn;(g.status==="dirty"||I.status==="dirty")&&e.dirty(),r.set(g.value,I.value)}return{status:e.value,value:r}})}else{const r=new Map;for(const a of s){const g=a.key,I=a.value;if(g.status==="aborted"||I.status==="aborted")return Qn;(g.status==="dirty"||I.status==="dirty")&&e.dirty(),r.set(g.value,I.value)}return{status:e.value,value:r}}}}exA.create=(t,A,e)=>new exA({valueType:A,keyType:t,typeName:Fn.ZodMap,...Ds(e)});class W1 extends Cr{_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.parsedType!==Oi.set)return bi(i,{code:Wt.invalid_type,expected:Oi.set,received:i.parsedType}),Qn;const o=this._def;o.minSize!==null&&i.data.size<o.minSize.value&&(bi(i,{code:Wt.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),e.dirty()),o.maxSize!==null&&i.data.size>o.maxSize.value&&(bi(i,{code:Wt.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),e.dirty());const n=this._def.valueType;function s(a){const g=new Set;for(const I of a){if(I.status==="aborted")return Qn;I.status==="dirty"&&e.dirty(),g.add(I.value)}return{status:e.value,value:g}}const r=[...i.data.values()].map((a,g)=>n._parse(new ow(i,a,i.path,g)));return i.common.async?Promise.all(r).then(a=>s(a)):s(r)}min(A,e){return new W1({...this._def,minSize:{value:A,message:wo.toString(e)}})}max(A,e){return new W1({...this._def,maxSize:{value:A,message:wo.toString(e)}})}size(A,e){return this.min(A,e).max(A,e)}nonempty(A){return this.min(1,A)}}W1.create=(t,A)=>new W1({valueType:t,minSize:null,maxSize:null,typeName:Fn.ZodSet,...Ds(A)});class Z1 extends Cr{constructor(){super(...arguments),this.validate=this.implement}_parse(A){const{ctx:e}=this._processInputParams(A);if(e.parsedType!==Oi.function)return bi(e,{code:Wt.invalid_type,expected:Oi.function,received:e.parsedType}),Qn;function i(r,a){return xz({data:r,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,bz(),T1].filter(g=>!!g),issueData:{code:Wt.invalid_arguments,argumentsError:a}})}function o(r,a){return xz({data:r,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,bz(),T1].filter(g=>!!g),issueData:{code:Wt.invalid_return_type,returnTypeError:a}})}const n={errorMap:e.common.contextualErrorMap},s=e.data;if(this._def.returns instanceof V1){const r=this;return vp(async function(...a){const g=new j0([]),I=await r._def.args.parseAsync(a,n).catch(C=>{throw g.addIssue(i(a,C)),g}),c=await Reflect.apply(s,this,I);return await r._def.returns._def.type.parseAsync(c,n).catch(C=>{throw g.addIssue(o(c,C)),g})})}else{const r=this;return vp(function(...a){const g=r._def.args.safeParse(a,n);if(!g.success)throw new j0([i(a,g.error)]);const I=Reflect.apply(s,this,g.data),c=r._def.returns.safeParse(I,n);if(!c.success)throw new j0([o(I,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...A){return new Z1({...this._def,args:UD.create(A).rest(sR.create())})}returns(A){return new Z1({...this._def,returns:A})}implement(A){return this.parse(A)}strictImplement(A){return this.parse(A)}static create(A,e,i){return new Z1({args:A||UD.create([]).rest(sR.create()),returns:e||sR.create(),typeName:Fn.ZodFunction,...Ds(i)})}}class Nz extends Cr{get schema(){return this._def.getter()}_parse(A){const{ctx:e}=this._processInputParams(A);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}Nz.create=(t,A)=>new Nz({getter:t,typeName:Fn.ZodLazy,...Ds(A)});class AT extends Cr{_parse(A){if(A.data!==this._def.value){const e=this._getOrReturnCtx(A);return bi(e,{received:e.data,code:Wt.invalid_literal,expected:this._def.value}),Qn}return{status:"valid",value:A.data}}get value(){return this._def.value}}AT.create=(t,A)=>new AT({value:t,typeName:Fn.ZodLiteral,...Ds(A)});function txA(t,A){return new jk({values:t,typeName:Fn.ZodEnum,...Ds(A)})}class jk extends Cr{_parse(A){if(typeof A.data!="string"){const e=this._getOrReturnCtx(A),i=this._def.values;return bi(e,{expected:ca.joinValues(i),received:e.parsedType,code:Wt.invalid_type}),Qn}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(A.data)){const e=this._getOrReturnCtx(A),i=this._def.values;return bi(e,{received:e.data,code:Wt.invalid_enum_value,options:i}),Qn}return vp(A.data)}get options(){return this._def.values}get enum(){const A={};for(const e of this._def.values)A[e]=e;return A}get Values(){const A={};for(const e of this._def.values)A[e]=e;return A}get Enum(){const A={};for(const e of this._def.values)A[e]=e;return A}extract(A,e=this._def){return jk.create(A,{...this._def,...e})}exclude(A,e=this._def){return jk.create(this.options.filter(i=>!A.includes(i)),{...this._def,...e})}}jk.create=txA;class Mz extends Cr{_parse(A){const e=ca.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(A);if(i.parsedType!==Oi.string&&i.parsedType!==Oi.number){const o=ca.objectValues(e);return bi(i,{expected:ca.joinValues(o),received:i.parsedType,code:Wt.invalid_type}),Qn}if(this._cache||(this._cache=new Set(ca.getValidEnumValues(this._def.values))),!this._cache.has(A.data)){const o=ca.objectValues(e);return bi(i,{received:i.data,code:Wt.invalid_enum_value,options:o}),Qn}return vp(A.data)}get enum(){return this._def.values}}Mz.create=(t,A)=>new Mz({values:t,typeName:Fn.ZodNativeEnum,...Ds(A)});class V1 extends Cr{unwrap(){return this._def.type}_parse(A){const{ctx:e}=this._processInputParams(A);if(e.parsedType!==Oi.promise&&e.common.async===!1)return bi(e,{code:Wt.invalid_type,expected:Oi.promise,received:e.parsedType}),Qn;const i=e.parsedType===Oi.promise?e.data:Promise.resolve(e.data);return vp(i.then(o=>this._def.type.parseAsync(o,{path:e.path,errorMap:e.common.contextualErrorMap})))}}V1.create=(t,A)=>new V1({type:t,typeName:Fn.ZodPromise,...Ds(A)});class zk extends Cr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Fn.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(A){const{status:e,ctx:i}=this._processInputParams(A),o=this._def.effect||null,n={addIssue:s=>{bi(i,s),s.fatal?e.abort():e.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),o.type==="preprocess"){const s=o.transform(i.data,n);if(i.common.async)return Promise.resolve(s).then(async r=>{if(e.value==="aborted")return Qn;const a=await this._def.schema._parseAsync({data:r,path:i.path,parent:i});return a.status==="aborted"?Qn:a.status==="dirty"||e.value==="dirty"?q1(a.value):a});{if(e.value==="aborted")return Qn;const r=this._def.schema._parseSync({data:s,path:i.path,parent:i});return r.status==="aborted"?Qn:r.status==="dirty"||e.value==="dirty"?q1(r.value):r}}if(o.type==="refinement"){const s=r=>{const a=o.refinement(r,n);if(i.common.async)return Promise.resolve(a);if(a instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return r};if(i.common.async===!1){const r=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return r.status==="aborted"?Qn:(r.status==="dirty"&&e.dirty(),s(r.value),{status:e.value,value:r.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(r=>r.status==="aborted"?Qn:(r.status==="dirty"&&e.dirty(),s(r.value).then(()=>({status:e.value,value:r.value}))))}if(o.type==="transform")if(i.common.async===!1){const s=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!oR(s))return Qn;const r=o.transform(s.value,n);if(r instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:r}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(s=>oR(s)?Promise.resolve(o.transform(s.value,n)).then(r=>({status:e.value,value:r})):Qn);ca.assertNever(o)}}zk.create=(t,A,e)=>new zk({schema:t,typeName:Fn.ZodEffects,effect:A,...Ds(e)}),zk.createWithPreprocess=(t,A,e)=>new zk({schema:A,effect:{type:"preprocess",transform:t},typeName:Fn.ZodEffects,...Ds(e)});class LD extends Cr{_parse(A){return this._getType(A)===Oi.undefined?vp(void 0):this._def.innerType._parse(A)}unwrap(){return this._def.innerType}}LD.create=(t,A)=>new LD({innerType:t,typeName:Fn.ZodOptional,...Ds(A)});class Xk extends Cr{_parse(A){return this._getType(A)===Oi.null?vp(null):this._def.innerType._parse(A)}unwrap(){return this._def.innerType}}Xk.create=(t,A)=>new Xk({innerType:t,typeName:Fn.ZodNullable,...Ds(A)});class eT extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A);let i=e.data;return e.parsedType===Oi.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}eT.create=(t,A)=>new eT({innerType:t,typeName:Fn.ZodDefault,defaultValue:typeof A.default=="function"?A.default:()=>A.default,...Ds(A)});class tT extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A),i={...e,common:{...e.common,issues:[]}},o=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return ZK(o)?o.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new j0(i.common.issues)},input:i.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new j0(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}}tT.create=(t,A)=>new tT({innerType:t,typeName:Fn.ZodCatch,catchValue:typeof A.catch=="function"?A.catch:()=>A.catch,...Ds(A)});class ixA extends Cr{_parse(A){if(this._getType(A)!==Oi.nan){const i=this._getOrReturnCtx(A);return bi(i,{code:Wt.invalid_type,expected:Oi.nan,received:i.parsedType}),Qn}return{status:"valid",value:A.data}}}ixA.create=t=>new ixA({typeName:Fn.ZodNaN,...Ds(t)});class oxA extends Cr{_parse(A){const{ctx:e}=this._processInputParams(A),i=e.data;return this._def.type._parse({data:i,path:e.path,parent:e})}unwrap(){return this._def.type}}class vz extends Cr{_parse(A){const{status:e,ctx:i}=this._processInputParams(A);if(i.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?Qn:n.status==="dirty"?(e.dirty(),q1(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{const o=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?Qn:o.status==="dirty"?(e.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:i.path,parent:i})}}static create(A,e){return new vz({in:A,out:e,typeName:Fn.ZodPipeline})}}class iT extends Cr{_parse(A){const e=this._def.innerType._parse(A),i=o=>(oR(o)&&(o.value=Object.freeze(o.value)),o);return ZK(e)?e.then(o=>i(o)):i(e)}unwrap(){return this._def.innerType}}iT.create=(t,A)=>new iT({innerType:t,typeName:Fn.ZodReadonly,...Ds(A)});function nxA(t,A){const e=typeof t=="function"?t(A):typeof t=="string"?{message:t}:t;return typeof e=="string"?{message:e}:e}function gh(t,A={},e){return t?O1.create().superRefine((i,o)=>{const n=t(i);if(n instanceof Promise)return n.then(s=>{if(!s){const r=nxA(A,i),a=r.fatal??e??!0;o.addIssue({code:"custom",...r,fatal:a})}});if(!n){const s=nxA(A,i),r=s.fatal??e??!0;o.addIssue({code:"custom",...s,fatal:r})}}):O1.create()}var Fn;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Fn||(Fn={}));const v=MD.create,NA=nR.create,te=Gz.create,sxA=jK.create,Yg=O1.create,cbe=sR.create;bb.create;const fe=nw.create,xA=Sl.create,Zt=zK.create,rE=_z.create;XK.create,UD.create;const $r=$K.create,xb=Z1.create,lA=AT.create,Ze=jk.create,kb=V1.create;LD.create,Xk.create;var rxA={Hz:{baseUnit:"Hz",variants:{MHz:1e6,kHz:1e3,Hz:1}},g:{baseUnit:"g",variants:{kg:1e3,g:1}},Ω:{baseUnit:"Ω",variants:{mΩ:.001,Ω:1,kΩ:1e3,KΩ:1e3,kohm:1e3,MΩ:1e6,GΩ:1e9,TΩ:1e12}},V:{baseUnit:"V",variants:{mV:.001,V:1,kV:1e3,KV:1e3,MV:1e6,GV:1e9,TV:1e12}},A:{baseUnit:"A",variants:{µA:1e-6,mA:.001,ma:.001,A:1,kA:1e3,MA:1e6}},F:{baseUnit:"F",variants:{pF:1e-12,nF:1e-9,µF:1e-6,uF:1e-6,mF:.001,F:1}},ml:{baseUnit:"ml",variants:{ml:1,mL:1,l:1e3,L:1e3}},deg:{baseUnit:"deg",variants:{rad:180/Math.PI}},ms:{baseUnit:"ms",variants:{fs:1e-12,ps:1e-9,ns:1e-6,us:.001,µs:.001,ms:1,s:1e3}},mm:{baseUnit:"mm",variants:{nm:1e-6,µm:.001,um:.001,mm:1,cm:10,dm:100,m:1e3,km:1e6,in:25.4,ft:304.8,IN:25.4,FT:304.8,yd:914.4,mi:1609344,mil:.0254}}},Uz=new Set;for(const[t,A]of Object.entries(rxA)){Uz.add(t);for(const e of Object.keys(A.variants))Uz.add(e)}function Bbe(t){for(const[A,e]of Object.entries(rxA))if(t in e.variants)return{baseUnit:e.baseUnit,conversionFactor:e.variants[t]};return{baseUnit:t,conversionFactor:1}}var axA={tera:1e12,T:1e12,giga:1e9,G:1e9,mega:1e6,M:1e6,kilo:1e3,k:1e3,deci:.1,d:.1,centi:.01,c:.01,milli:.001,m:.001,micro:1e-6,u:1e-6,µ:1e-6,nano:1e-9,n:1e-9,pico:1e-12,p:1e-12};function nm(t){if(t==null)return{parsedUnit:null,unitOfValue:null,value:null};if(typeof t=="string"&&t.match(/^-?[\d\.]+$/))return{value:Number.parseFloat(t),parsedUnit:null,unitOfValue:null};if(typeof t=="number")return{value:t,parsedUnit:null,unitOfValue:null};if(typeof t=="object"&&"x"in t&&"y"in t){const{parsedUnit:r,unitOfValue:a}=nm(t.x),g=nm(t.x),I=nm(t.y);return g.value===null||I.value===null?{parsedUnit:null,unitOfValue:null,value:null}:{parsedUnit:r,unitOfValue:a,value:{x:g.value,y:I.value}}}const e=t.toString().split("").reverse().join("").match(/[^\d\s]+/)?.[0];if(!e)throw new Error(`Could not determine unit: "${t}"`);const i=e.split("").reverse().join(""),o=t.slice(0,-i.length);if(i in axA&&!Uz.has(i)){const r=axA[i];return{parsedUnit:null,unitOfValue:null,value:Number.parseFloat(o)*r}}const{baseUnit:n,conversionFactor:s}=Bbe(i);return{parsedUnit:i,unitOfValue:n,value:s*Number.parseFloat(o)}}var aR=v().or(NA()).transform(t=>nm(t).value),gR=v().or(NA()).transform(t=>nm(t).value).transform(t=>Number.parseFloat(t.toPrecision(12))),Lz=v().or(NA()).transform(t=>nm(t).value),z0=v().or(NA()).transform(t=>nm(t).value),VA=v().or(NA()).transform(t=>nm(t).value),HD=v().or(NA()).transform(t=>nm(t).value),Ie=VA,Cbe=v().or(NA()).transform(t=>nm(t).value),j1=v().or(NA()).transform(t=>nm(t).value),lbe=j1,Tf=j1,gxA=v().datetime(),BI=v().or(NA()).transform(t=>typeof t=="number"?t:t.endsWith("deg")?Number.parseFloat(t.split("deg")[0]):t.endsWith("rad")?Number.parseFloat(t.split("rad")[0])*180/Math.PI:Number.parseFloat(t)),IxA=NA().or(v().endsWith("mAh")).transform(t=>{if(typeof t=="string"){const A=t.replace("mAh",""),e=Number.parseFloat(A);if(Number.isNaN(e))throw new Error("Invalid capacity");return e}return t}).describe("Battery capacity in mAh"),co=xA({x:Ie,y:Ie}),Qbe=co,IR=xA({x:Ie,y:Ie,z:Ie}),Ebe=IR,Hz=xA({width:NA(),height:NA()}),hbe=t=>{const A="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";return Array.from({length:t},()=>A[Math.floor(Math.random()*A.length)]).join("")},Ai=t=>v().optional().default(()=>`${t}_${hbe(10)}`),$k=Ze(["top_left","top_center","top_right","center_left","center","center_right","bottom_left","bottom_center","bottom_right"]),oT=Ze(["jlcpcb","macrofab","pcbway","digikey","mouser","lcsc"]),dB=xA({type:lA("source_component"),ftype:v().optional(),source_component_id:v(),name:v(),manufacturer_part_number:v().optional(),supplier_part_numbers:$r(oT,fe(v())).optional(),display_value:v().optional(),are_pins_interchangeable:te().optional(),internally_connected_source_port_ids:fe(fe(v())).optional(),source_group_id:v().optional(),subcircuit_id:v().optional()}),Yz=dB.extend({ftype:lA("simple_capacitor"),capacitance:gR,max_voltage_rating:z0.optional(),display_capacitance:v().optional(),max_decoupling_trace_length:Ie.optional()}),Jz=dB.extend({ftype:lA("simple_resistor"),resistance:aR,display_resistance:v().optional()}),nT=dB.extend({ftype:lA("simple_diode")}),cxA=dB.extend({ftype:lA("simple_fiducial")}),Kz=nT.extend({ftype:lA("simple_led"),color:v().optional(),wavelength:v().optional()}),BxA=dB.extend({ftype:lA("simple_ground")}),Tz=dB.extend({ftype:lA("simple_chip")}),qz=dB.extend({ftype:lA("simple_power_source"),voltage:z0}),ube=dB.extend({ftype:lA("simple_fuse"),current_rating_amps:NA().describe("Nominal current in amps the fuse is rated for"),voltage_rating_volts:NA().describe("Voltage rating in volts, e.g. ±5V would be 5")}),Pz=dB.extend({ftype:lA("simple_battery"),capacity:IxA}),Oz=dB.extend({ftype:lA("simple_inductor"),inductance:Lz,max_current_rating:NA().optional()}),Wz=dB.extend({ftype:lA("simple_push_button")}),Zz=dB.extend({ftype:lA("simple_potentiometer"),max_resistance:aR}),CxA=dB.extend({ftype:lA("simple_crystal"),frequency:NA().describe("Frequency in Hz"),load_capacitance:NA().optional().describe("Load capacitance in pF")}),Vz=dB.extend({ftype:lA("simple_pin_header"),pin_count:NA(),gender:Ze(["male","female"]).optional().default("male")}),jz=dB.extend({ftype:lA("simple_pinout")}),zz=dB.extend({ftype:lA("simple_resonator"),load_capacitance:gR,equivalent_series_resistance:aR.optional(),frequency:HD}),Xz=dB.extend({ftype:lA("simple_transistor"),transistor_type:Ze(["npn","pnp"])}),$z=dB.extend({ftype:lA("simple_test_point"),footprint_variant:Ze(["pad","through_hole"]).optional(),pad_shape:Ze(["rect","circle"]).optional(),pad_diameter:Zt([NA(),v()]).optional(),hole_diameter:Zt([NA(),v()]).optional(),width:Zt([NA(),v()]).optional(),height:Zt([NA(),v()]).optional()}),AX=dB.extend({ftype:lA("simple_mosfet"),channel_type:Ze(["n","p"]),mosfet_mode:Ze(["enhancement","depletion"])}),eX=dB.extend({ftype:lA("simple_switch")}),tX=xA({type:lA("source_project_metadata"),name:v().optional(),software_used_string:v().optional(),project_url:v().optional(),created_at:gxA.optional()}),lxA=xA({type:lA("source_missing_property_error"),source_missing_property_error_id:Ai("source_missing_property_error"),source_component_id:v(),property_name:v(),subcircuit_id:v().optional(),error_type:lA("source_missing_property_error").default("source_missing_property_error"),message:v()}).describe("The source code is missing a property"),QxA=xA({type:lA("source_failed_to_create_component_error"),source_failed_to_create_component_error_id:Ai("source_failed_to_create_component_error"),error_type:lA("source_failed_to_create_component_error").default("source_failed_to_create_component_error"),component_name:v().optional(),subcircuit_id:v().optional(),parent_source_component_id:v().optional(),message:v(),pcb_center:xA({x:NA().optional(),y:NA().optional()}).optional(),schematic_center:xA({x:NA().optional(),y:NA().optional()}).optional()}).describe("Error emitted when a component fails to be constructed"),iX=xA({type:lA("source_trace_not_connected_error"),source_trace_not_connected_error_id:Ai("source_trace_not_connected_error"),error_type:lA("source_trace_not_connected_error").default("source_trace_not_connected_error"),message:v(),subcircuit_id:v().optional(),source_group_id:v().optional(),source_trace_id:v().optional(),connected_source_port_ids:fe(v()).optional(),selectors_not_found:fe(v()).optional()}).describe("Occurs when a source trace selector does not match any ports"),ExA=xA({type:lA("source_property_ignored_warning"),source_property_ignored_warning_id:Ai("source_property_ignored_warning"),source_component_id:v(),property_name:v(),subcircuit_id:v().optional(),error_type:lA("source_property_ignored_warning").default("source_property_ignored_warning"),message:v()}).describe("The source property was ignored"),oX=xA({type:lA("source_pin_missing_trace_warning"),source_pin_missing_trace_warning_id:Ai("source_pin_missing_trace_warning"),warning_type:lA("source_pin_missing_trace_warning").default("source_pin_missing_trace_warning"),message:v(),source_component_id:v(),source_port_id:v(),subcircuit_id:v().optional()}).describe("Warning emitted when a source component pin is missing a trace connection"),hxA=dB.extend({ftype:lA("simple_voltage_probe")}),uxA=dB.extend({ftype:lA("interconnect")}),dxA=Zt([Jz,Yz,nT,cxA,Kz,BxA,Tz,qz,Pz,Oz,Wz,Zz,CxA,Vz,jz,zz,eX,Xz,$z,AX,ube,hxA,uxA,tX,lxA,QxA,iX,ExA,oX]),pxA=xA({type:lA("source_port"),pin_number:NA().optional(),port_hints:fe(v()).optional(),name:v(),source_port_id:v(),source_component_id:v().optional(),source_group_id:v().optional(),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),must_be_connected:te().optional()}),fxA=xA({type:lA("source_component_internal_connection"),source_component_internal_connection_id:v(),source_component_id:v(),source_port_ids:fe(v()),subcircuit_id:v().optional()}),yxA=xA({type:lA("source_trace"),source_trace_id:v(),connected_source_port_ids:fe(v()),connected_source_net_ids:fe(v()),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),max_length:NA().optional(),min_trace_thickness:NA().optional(),display_name:v().optional()}),mxA=xA({type:lA("source_group"),source_group_id:v(),subcircuit_id:v().optional(),parent_subcircuit_id:v().optional(),parent_source_group_id:v().optional(),is_subcircuit:te().optional(),show_as_schematic_box:te().optional(),name:v().optional(),was_automatically_named:te().optional()}),wxA=xA({type:lA("source_net"),source_net_id:v(),name:v(),member_source_group_ids:fe(v()),is_power:te().optional(),is_ground:te().optional(),is_digital_signal:te().optional(),is_analog_signal:te().optional(),is_positive_voltage_source:te().optional(),trace_width:NA().optional(),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional()}),DxA=xA({type:lA("source_board"),source_board_id:v(),source_group_id:v(),title:v().optional()}).describe("Defines a board in the source domain"),SxA=xA({type:lA("source_pcb_ground_plane"),source_pcb_ground_plane_id:v(),source_group_id:v(),source_net_id:v(),subcircuit_id:v().optional()}).describe("Defines a ground plane in the source domain"),z1=["top","bottom","inner1","inner2","inner3","inner4","inner5","inner6"],nX=Ze(z1),ss=nX.or(xA({name:nX})).transform(t=>typeof t=="string"?t:t.name),sm=Ze(["top","bottom"]),bxA=xA({type:lA("source_manually_placed_via"),source_manually_placed_via_id:v(),source_group_id:v(),source_net_id:v(),subcircuit_id:v().optional(),source_trace_id:v().optional()}).describe("Defines a via that is manually placed in the source domain"),xxA=xA({type:lA("source_pin_must_be_connected_error"),source_pin_must_be_connected_error_id:Ai("source_pin_must_be_connected_error"),error_type:lA("source_pin_must_be_connected_error").default("source_pin_must_be_connected_error"),message:v(),source_component_id:v(),source_port_id:v(),subcircuit_id:v().optional()}).describe("Error emitted when a pin with mustBeConnected attribute is not connected to any trace"),sX=xA({type:lA("unknown_error_finding_part"),unknown_error_finding_part_id:Ai("unknown_error_finding_part"),error_type:lA("unknown_error_finding_part").default("unknown_error_finding_part"),message:v(),source_component_id:v().optional(),subcircuit_id:v().optional()}).describe("Error emitted when an unexpected error occurs while finding a part"),kxA=xA({type:lA("schematic_box"),schematic_component_id:v().optional(),width:Ie,height:Ie,is_dashed:te().default(!1),x:Ie,y:Ie,subcircuit_id:v().optional()}).describe("Draws a box on the schematic"),GxA=xA({type:lA("schematic_path"),schematic_component_id:v(),fill_color:Ze(["red","blue"]).optional(),is_filled:te().optional(),points:fe(co),subcircuit_id:v().optional()}),FxA=$r(xA({left_margin:VA.optional(),right_margin:VA.optional(),top_margin:VA.optional(),bottom_margin:VA.optional()})),_xA=xA({left_size:NA(),right_size:NA(),top_size:NA().optional(),bottom_size:NA().optional()}),RxA=xA({left_side:xA({pins:fe(NA()),direction:Ze(["top-to-bottom","bottom-to-top"]).optional()}).optional(),right_side:xA({pins:fe(NA()),direction:Ze(["top-to-bottom","bottom-to-top"]).optional()}).optional(),top_side:xA({pins:fe(NA()),direction:Ze(["left-to-right","right-to-left"]).optional()}).optional(),bottom_side:xA({pins:fe(NA()),direction:Ze(["left-to-right","right-to-left"]).optional()}).optional()}),NxA=Zt([_xA,RxA]),MxA=xA({type:lA("schematic_component"),size:Hz,center:co,source_component_id:v().optional(),schematic_component_id:v(),pin_spacing:VA.optional(),pin_styles:FxA.optional(),box_width:VA.optional(),symbol_name:v().optional(),port_arrangement:NxA.optional(),port_labels:$r(v()).optional(),symbol_display_value:v().optional(),subcircuit_id:v().optional(),schematic_group_id:v().optional(),is_schematic_group:te().optional(),source_group_id:v().optional(),is_box_with_pins:te().optional().default(!0)}),vxA=xA({type:lA("schematic_line"),schematic_line_id:Ai("schematic_line"),schematic_component_id:v(),x1:Ie,y1:Ie,x2:Ie,y2:Ie,stroke_width:Ie.nullable().optional(),color:v().default("#000000"),is_dashed:te().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled line on the schematic"),UxA=xA({type:lA("schematic_rect"),schematic_rect_id:Ai("schematic_rect"),schematic_component_id:v(),center:co,width:Ie,height:Ie,rotation:BI.default(0),stroke_width:Ie.nullable().optional(),color:v().default("#000000"),is_filled:te().default(!1),fill_color:v().optional(),is_dashed:te().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled rectangle on the schematic"),LxA=xA({type:lA("schematic_circle"),schematic_circle_id:Ai("schematic_circle"),schematic_component_id:v(),center:co,radius:Ie,stroke_width:Ie.nullable().optional(),color:v().default("#000000"),is_filled:te().default(!1),fill_color:v().optional(),is_dashed:te().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled circle on the schematic"),HxA=xA({type:lA("schematic_arc"),schematic_arc_id:Ai("schematic_arc"),schematic_component_id:v(),center:co,radius:Ie,start_angle_degrees:BI,end_angle_degrees:BI,direction:Ze(["clockwise","counterclockwise"]).default("counterclockwise"),stroke_width:Ie.nullable().optional(),color:v().default("#000000"),is_dashed:te().default(!1),subcircuit_id:v().optional()}).describe("Draws a styled arc on the schematic"),YxA=xA({type:lA("schematic_trace"),schematic_trace_id:v(),source_trace_id:v().optional(),junctions:fe(xA({x:NA(),y:NA()})),edges:fe(xA({from:xA({x:NA(),y:NA()}),to:xA({x:NA(),y:NA()}),is_crossing:te().optional(),from_schematic_port_id:v().optional(),to_schematic_port_id:v().optional()})),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional()}),dbe=Ze(["center","left","right","top","bottom"]),JxA=xA({type:lA("schematic_text"),schematic_component_id:v().optional(),schematic_text_id:v(),text:v(),font_size:NA().default(.18),position:xA({x:Ie,y:Ie}),rotation:NA().default(0),anchor:Zt([dbe.describe("legacy"),$k]).default("center"),color:v().default("#000000"),subcircuit_id:v().optional()}),KxA=xA({type:lA("schematic_port"),schematic_port_id:v(),source_port_id:v(),schematic_component_id:v().optional(),center:co,facing_direction:Ze(["up","down","left","right"]).optional(),distance_from_component_edge:NA().optional(),side_of_component:Ze(["top","bottom","left","right"]).optional(),true_ccw_index:NA().optional(),pin_number:NA().optional(),display_pin_label:v().optional(),subcircuit_id:v().optional(),is_connected:te().optional(),has_input_arrow:te().optional(),has_output_arrow:te().optional()}).describe("Defines a port on a schematic component"),TxA=xA({type:lA("schematic_net_label"),schematic_net_label_id:Ai("schematic_net_label"),schematic_trace_id:v().optional(),source_trace_id:v().optional(),source_net_id:v(),center:co,anchor_position:co.optional(),anchor_side:Ze(["top","bottom","left","right"]),text:v(),symbol_name:v().optional(),is_movable:te().optional(),subcircuit_id:v().optional()}),qxA=xA({type:lA("schematic_error"),schematic_error_id:v(),error_type:lA("schematic_port_not_found").default("schematic_port_not_found"),message:v(),subcircuit_id:v().optional()}).describe("Defines a schematic error on the schematic"),PxA=xA({type:lA("schematic_layout_error"),schematic_layout_error_id:Ai("schematic_layout_error"),error_type:lA("schematic_layout_error").default("schematic_layout_error"),message:v(),source_group_id:v(),schematic_group_id:v(),subcircuit_id:v().optional()}).describe("Error emitted when schematic layout fails for a group"),sT=xA({type:lA("schematic_debug_object"),label:v().optional(),subcircuit_id:v().optional()}),OxA=sT.extend({shape:lA("rect"),center:co,size:Hz}),WxA=sT.extend({shape:lA("line"),start:co,end:co}),ZxA=sT.extend({shape:lA("point"),center:co}),VxA=rE("shape",[OxA,WxA,ZxA]),jxA=xA({type:lA("schematic_voltage_probe"),schematic_voltage_probe_id:v(),source_component_id:v().optional(),name:v().optional(),position:co,schematic_trace_id:v(),voltage:z0.optional(),subcircuit_id:v().optional(),color:v().optional(),label_alignment:$k.optional()}).describe("Defines a voltage probe measurement point on a schematic trace"),rX=xA({type:lA("schematic_manual_edit_conflict_warning"),schematic_manual_edit_conflict_warning_id:Ai("schematic_manual_edit_conflict_warning"),warning_type:lA("schematic_manual_edit_conflict_warning").default("schematic_manual_edit_conflict_warning"),message:v(),schematic_component_id:v(),schematic_group_id:v().optional(),subcircuit_id:v().optional(),source_component_id:v()}).describe("Warning emitted when a component has both manual placement and explicit schX/schY coordinates"),zxA=xA({type:lA("schematic_group"),schematic_group_id:Ai("schematic_group"),source_group_id:v(),is_subcircuit:te().optional(),subcircuit_id:v().optional(),width:VA,height:VA,center:co,schematic_component_ids:fe(v()),show_as_schematic_box:te().optional(),name:v().optional(),description:v().optional()}).describe("Defines a group of components on the schematic"),XxA=xA({type:lA("schematic_table"),schematic_table_id:Ai("schematic_table"),anchor_position:co,column_widths:fe(Ie),row_heights:fe(Ie),cell_padding:Ie.optional(),border_width:Ie.optional(),subcircuit_id:v().optional(),schematic_component_id:v().optional(),anchor:$k.optional()}).describe("Defines a table on the schematic"),$xA=xA({type:lA("schematic_table_cell"),schematic_table_cell_id:Ai("schematic_table_cell"),schematic_table_id:v(),start_row_index:NA(),end_row_index:NA(),start_column_index:NA(),end_column_index:NA(),text:v().optional(),center:co,width:Ie,height:Ie,horizontal_align:Ze(["left","center","right"]).optional(),vertical_align:Ze(["top","middle","bottom"]).optional(),font_size:Ie.optional(),subcircuit_id:v().optional()}).describe("Defines a cell within a schematic_table"),AkA=xA({type:lA("schematic_sheet"),schematic_sheet_id:Ai("schematic_sheet"),name:v().optional(),subcircuit_id:v().optional()}).describe("Defines a schematic sheet or page that components can be placed on"),ekA=xA({x:Ie,y:Ie,bulge:NA().optional()}),aX=xA({vertices:fe(ekA)}),tkA=xA({outer_ring:aX,inner_rings:fe(aX).default([])}),ikA=xA({x:Ie,y:Ie,via:te().optional(),via_to_layer:ss.optional()}),pbe=fe(ikA),sw=xA({x:Ie,y:Ie,via:te().optional(),to_layer:ss.optional(),trace_width:Ie.optional()}),okA=xA({type:lA("pcb_component"),pcb_component_id:Ai("pcb_component"),source_component_id:v(),center:co,layer:ss,rotation:BI,display_offset_x:v().optional().describe("How to display the x offset for this part, usually corresponding with how the user specified it"),display_offset_y:v().optional().describe("How to display the y offset for this part, usually corresponding with how the user specified it"),width:VA,height:VA,do_not_place:te().optional(),subcircuit_id:v().optional(),pcb_group_id:v().optional(),position_mode:Ze(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:v().optional(),positioned_relative_to_pcb_board_id:v().optional(),obstructs_within_bounds:te().default(!0).describe("Does this component take up all the space within its bounds on a layer. This is generally true except for when separated pin headers are being represented by a single component (in which case, chips can be placed between the pin headers) or for tall modules where chips fit underneath")}).describe("Defines a component on the PCB"),nkA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:lA("circle"),hole_diameter:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),fbe=nkA.describe("Defines a circular hole on the PCB"),skA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:lA("rect"),hole_width:NA(),hole_height:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),ybe=skA.describe("Defines a rectangular (square-capable) hole on the PCB. Use equal width/height for square."),rkA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:Ze(["circle","square"]),hole_diameter:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),mbe=rkA.describe("Defines a circular or square hole on the PCB"),akA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:lA("oval"),hole_width:NA(),hole_height:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),wbe=akA.describe("Defines an oval hole on the PCB"),gkA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:lA("pill"),hole_width:NA(),hole_height:NA(),x:Ie,y:Ie,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Dbe=gkA.describe("Defines a pill-shaped hole on the PCB"),IkA=xA({type:lA("pcb_hole"),pcb_hole_id:Ai("pcb_hole"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_component_id:v().optional(),hole_shape:lA("rotated_pill"),hole_width:NA(),hole_height:NA(),x:Ie,y:Ie,ccw_rotation:BI,is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Sbe=IkA.describe("Defines a rotated pill-shaped hole on the PCB"),ckA=rkA.or(akA).or(gkA).or(IkA).or(nkA).or(skA),bbe=xA({type:lA("pcb_plated_hole"),shape:lA("circle"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),outer_diameter:NA(),hole_diameter:NA(),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),xbe=xA({type:lA("pcb_plated_hole"),shape:Ze(["oval","pill"]),pcb_group_id:v().optional(),subcircuit_id:v().optional(),outer_width:NA(),outer_height:NA(),hole_width:NA(),hole_height:NA(),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,ccw_rotation:BI,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),kbe=xA({type:lA("pcb_plated_hole"),shape:lA("circular_hole_with_rect_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("circle"),pad_shape:lA("rect"),hole_diameter:NA(),rect_pad_width:NA(),rect_pad_height:NA(),rect_border_radius:NA().optional(),hole_offset_x:Ie.default(0),hole_offset_y:Ie.default(0),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),Gbe=xA({type:lA("pcb_plated_hole"),shape:lA("pill_hole_with_rect_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("pill"),pad_shape:lA("rect"),hole_width:NA(),hole_height:NA(),rect_pad_width:NA(),rect_pad_height:NA(),rect_border_radius:NA().optional(),hole_offset_x:Ie.default(0),hole_offset_y:Ie.default(0),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),Fbe=xA({type:lA("pcb_plated_hole"),shape:lA("rotated_pill_hole_with_rect_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:lA("rotated_pill"),pad_shape:lA("rect"),hole_width:NA(),hole_height:NA(),hole_ccw_rotation:BI,rect_pad_width:NA(),rect_pad_height:NA(),rect_border_radius:NA().optional(),rect_ccw_rotation:BI,hole_offset_x:Ie.default(0),hole_offset_y:Ie.default(0),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),_be=xA({type:lA("pcb_plated_hole"),shape:lA("hole_with_polygon_pad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),hole_shape:Ze(["circle","oval","pill","rotated_pill"]),hole_diameter:NA().optional(),hole_width:NA().optional(),hole_height:NA().optional(),pad_outline:fe(xA({x:Ie,y:Ie})).min(3),hole_offset_x:Ie.default(0),hole_offset_y:Ie.default(0),is_covered_with_solder_mask:te().optional(),x:Ie,y:Ie,layers:fe(ss),port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),pcb_plated_hole_id:Ai("pcb_plated_hole"),soldermask_margin:NA().optional()}),BkA=Zt([bbe,xbe,kbe,Gbe,Fbe,_be]),CkA=xA({type:lA("pcb_port"),pcb_port_id:Ai("pcb_port"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),source_port_id:v(),pcb_component_id:v().optional(),x:Ie,y:Ie,layers:fe(ss),is_board_pinout:te().optional()}).describe("Defines a port on the PCB"),Rbe=xA({type:lA("pcb_smtpad"),shape:lA("circle"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,radius:NA(),layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Nbe=xA({type:lA("pcb_smtpad"),shape:lA("rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),rect_border_radius:NA().optional(),corner_radius:NA().optional(),layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Mbe=xA({type:lA("pcb_smtpad"),shape:lA("rotated_rect"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),rect_border_radius:NA().optional(),corner_radius:NA().optional(),ccw_rotation:BI,layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),lkA=xA({type:lA("pcb_smtpad"),shape:lA("pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),radius:NA(),layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),vbe=xA({type:lA("pcb_smtpad"),shape:lA("rotated_pill"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),radius:NA(),ccw_rotation:BI,layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),Ube=xA({type:lA("pcb_smtpad"),shape:lA("polygon"),pcb_smtpad_id:Ai("pcb_smtpad"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),points:fe(co),layer:ss,port_hints:fe(v()).optional(),pcb_component_id:v().optional(),pcb_port_id:v().optional(),is_covered_with_solder_mask:te().optional(),soldermask_margin:NA().optional()}),QkA=rE("shape",[Rbe,Nbe,Mbe,vbe,lkA,Ube]).describe("Defines an SMT pad on the PCB"),Lbe=xA({type:lA("pcb_solder_paste"),shape:lA("circle"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,radius:NA(),layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Hbe=xA({type:lA("pcb_solder_paste"),shape:lA("rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Ybe=xA({type:lA("pcb_solder_paste"),shape:lA("pill"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),radius:NA(),layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Jbe=xA({type:lA("pcb_solder_paste"),shape:lA("rotated_rect"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),ccw_rotation:Ie,layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),Kbe=xA({type:lA("pcb_solder_paste"),shape:lA("oval"),pcb_solder_paste_id:Ai("pcb_solder_paste"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),x:Ie,y:Ie,width:NA(),height:NA(),layer:ss,pcb_component_id:v().optional(),pcb_smtpad_id:v().optional()}),EkA=Zt([Lbe,Hbe,Ybe,Jbe,Kbe]).describe("Defines solderpaste on the PCB"),hkA=xA({type:lA("pcb_text"),pcb_text_id:Ai("pcb_text"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),text:v(),center:co,layer:ss,width:VA,height:VA,lines:NA(),align:Ze(["bottom-left"])}).describe("Defines text on the PCB"),ukA=xA({route_type:lA("wire"),x:Ie,y:Ie,width:Ie,start_pcb_port_id:v().optional(),end_pcb_port_id:v().optional(),layer:ss}),dkA=xA({route_type:lA("via"),x:Ie,y:Ie,hole_diameter:Ie.optional(),outer_diameter:Ie.optional(),from_layer:v(),to_layer:v()}),gX=Zt([ukA,dkA]),pkA=xA({type:lA("pcb_trace"),source_trace_id:v().optional(),pcb_component_id:v().optional(),pcb_trace_id:Ai("pcb_trace"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),route_thickness_mode:Ze(["constant","interpolated"]).default("constant").optional(),route_order_index:NA().optional(),should_round_corners:te().optional(),trace_length:NA().optional(),highlight_color:v().optional(),route:fe(gX)}).describe("Defines a trace on the PCB"),fkA=xA({type:lA("pcb_trace_error"),pcb_trace_error_id:Ai("pcb_trace_error"),error_type:lA("pcb_trace_error").default("pcb_trace_error"),message:v(),center:co.optional(),pcb_trace_id:v(),source_trace_id:v(),pcb_component_ids:fe(v()),pcb_port_ids:fe(v()),subcircuit_id:v().optional()}).describe("Defines a trace error on the PCB"),ykA=xA({type:lA("pcb_trace_missing_error"),pcb_trace_missing_error_id:Ai("pcb_trace_missing_error"),error_type:lA("pcb_trace_missing_error").default("pcb_trace_missing_error"),message:v(),center:co.optional(),source_trace_id:v(),pcb_component_ids:fe(v()),pcb_port_ids:fe(v()),subcircuit_id:v().optional()}).describe("Defines an error when a source trace has no corresponding PCB trace"),mkA=xA({type:lA("pcb_port_not_matched_error"),pcb_error_id:Ai("pcb_error"),error_type:lA("pcb_port_not_matched_error").default("pcb_port_not_matched_error"),message:v(),pcb_component_ids:fe(v()),subcircuit_id:v().optional()}).describe("Defines a trace error on the PCB where a port is not matched"),wkA=xA({type:lA("pcb_port_not_connected_error"),pcb_port_not_connected_error_id:Ai("pcb_port_not_connected_error"),error_type:lA("pcb_port_not_connected_error").default("pcb_port_not_connected_error"),message:v(),pcb_port_ids:fe(v()),pcb_component_ids:fe(v()),subcircuit_id:v().optional()}).describe("Defines an error when a pcb port is not connected to any trace"),DkA=xA({type:lA("pcb_net"),pcb_net_id:Ai("pcb_net"),source_net_id:v().optional(),highlight_color:v().optional()}).describe("Defines a net on the PCB"),SkA=xA({type:lA("pcb_via"),pcb_via_id:Ai("pcb_via"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),x:Ie,y:Ie,outer_diameter:Ie.default("0.6mm"),hole_diameter:Ie.default("0.25mm"),from_layer:ss.optional(),to_layer:ss.optional(),layers:fe(ss),pcb_trace_id:v().optional(),net_is_assignable:te().optional(),net_assigned:te().optional(),is_tented:te().optional()}).describe("Defines a via on the PCB"),bkA=xA({type:lA("pcb_board"),pcb_board_id:Ai("pcb_board"),pcb_panel_id:v().optional(),is_subcircuit:te().optional(),subcircuit_id:v().optional(),width:VA.optional(),height:VA.optional(),center:co,thickness:VA.optional().default(1.4),num_layers:NA().optional().default(4),outline:fe(co).optional(),shape:Ze(["rect","polygon"]).optional(),material:Ze(["fr4","fr1"]).default("fr4")}).describe("Defines the board outline of the PCB"),xkA=xA({type:lA("pcb_panel"),pcb_panel_id:Ai("pcb_panel"),width:VA,height:VA,center:co,covered_with_solder_mask:te().optional().default(!0)}).describe("Defines a PCB panel that can contain multiple boards"),kkA=xA({type:lA("pcb_placement_error"),pcb_placement_error_id:Ai("pcb_placement_error"),error_type:lA("pcb_placement_error").default("pcb_placement_error"),message:v(),subcircuit_id:v().optional()}).describe("Defines a placement error on the PCB"),GkA=xA({type:lA("pcb_trace_hint"),pcb_trace_hint_id:Ai("pcb_trace_hint"),pcb_port_id:v(),pcb_component_id:v(),route:fe(sw),subcircuit_id:v().optional()}).describe("A hint that can be used during generation of a PCB trace"),FkA=xA({type:lA("pcb_silkscreen_line"),pcb_silkscreen_line_id:Ai("pcb_silkscreen_line"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),stroke_width:Ie.default("0.1mm"),x1:Ie,y1:Ie,x2:Ie,y2:Ie,layer:sm}).describe("Defines a silkscreen line on the PCB"),_kA=xA({type:lA("pcb_silkscreen_path"),pcb_silkscreen_path_id:Ai("pcb_silkscreen_path"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:sm,route:fe(co),stroke_width:VA}).describe("Defines a silkscreen path on the PCB"),RkA=xA({type:lA("pcb_silkscreen_text"),pcb_silkscreen_text_id:Ai("pcb_silkscreen_text"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:Ie.default("0.2mm"),pcb_component_id:v(),text:v(),is_knockout:te().default(!1).optional(),knockout_padding:xA({left:VA,top:VA,bottom:VA,right:VA}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:NA().optional(),layer:ss,is_mirrored:te().default(!1).optional(),anchor_position:co.default({x:0,y:0}),anchor_alignment:$k.default("center")}).describe("Defines silkscreen text on the PCB"),NkA=xA({type:lA("pcb_copper_text"),pcb_copper_text_id:Ai("pcb_copper_text"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:Ie.default("0.2mm"),pcb_component_id:v(),text:v(),is_knockout:te().default(!1).optional(),knockout_padding:xA({left:VA,top:VA,bottom:VA,right:VA}).default({left:"0.2mm",top:"0.2mm",bottom:"0.2mm",right:"0.2mm"}).optional(),ccw_rotation:NA().optional(),layer:ss,is_mirrored:te().default(!1).optional(),anchor_position:co.default({x:0,y:0}),anchor_alignment:$k.default("center")}).describe("Defines copper text on the PCB"),MkA=xA({type:lA("pcb_silkscreen_rect"),pcb_silkscreen_rect_id:Ai("pcb_silkscreen_rect"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,width:VA,height:VA,layer:ss,stroke_width:VA.default("1mm"),corner_radius:VA.optional(),is_filled:te().default(!0).optional(),has_stroke:te().optional(),is_stroke_dashed:te().optional()}).describe("Defines a silkscreen rect on the PCB"),vkA=xA({type:lA("pcb_silkscreen_circle"),pcb_silkscreen_circle_id:Ai("pcb_silkscreen_circle"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,radius:VA,layer:sm,stroke_width:VA.default("1mm")}).describe("Defines a silkscreen circle on the PCB"),UkA=xA({type:lA("pcb_silkscreen_oval"),pcb_silkscreen_oval_id:Ai("pcb_silkscreen_oval"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,radius_x:Ie,radius_y:Ie,layer:sm}).describe("Defines a silkscreen oval on the PCB"),LkA=xA({type:lA("pcb_fabrication_note_text"),pcb_fabrication_note_text_id:Ai("pcb_fabrication_note_text"),subcircuit_id:v().optional(),pcb_group_id:v().optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:Ie.default("1mm"),pcb_component_id:v(),text:v(),layer:sm,anchor_position:co.default({x:0,y:0}),anchor_alignment:Ze(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:v().optional()}).describe("Defines a fabrication note in text on the PCB, useful for leaving notes for assemblers or fabricators"),HkA=xA({type:lA("pcb_fabrication_note_path"),pcb_fabrication_note_path_id:Ai("pcb_fabrication_note_path"),pcb_component_id:v(),subcircuit_id:v().optional(),layer:ss,route:fe(co),stroke_width:VA,color:v().optional()}).describe("Defines a fabrication path on the PCB for fabricators or assemblers"),YkA=xA({type:lA("pcb_fabrication_note_rect"),pcb_fabrication_note_rect_id:Ai("pcb_fabrication_note_rect"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,width:VA,height:VA,layer:sm,stroke_width:VA.default("0.1mm"),corner_radius:VA.optional(),is_filled:te().optional(),has_stroke:te().optional(),is_stroke_dashed:te().optional(),color:v().optional()}).describe("Defines a fabrication note rectangle on the PCB"),JkA=xA({type:lA("pcb_fabrication_note_dimension"),pcb_fabrication_note_dimension_id:Ai("pcb_fabrication_note_dimension"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:sm,from:co,to:co,text:v().optional(),text_ccw_rotation:NA().optional(),offset:VA.optional(),offset_distance:VA.optional(),offset_direction:xA({x:NA(),y:NA()}).optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:VA.default("1mm"),color:v().optional(),arrow_size:VA.default("1mm")}).describe("Defines a measurement annotation within PCB fabrication notes"),KkA=xA({type:lA("pcb_note_text"),pcb_note_text_id:Ai("pcb_note_text"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:Ie.default("1mm"),text:v().optional(),anchor_position:co.default({x:0,y:0}),anchor_alignment:Ze(["center","top_left","top_right","bottom_left","bottom_right"]).default("center"),color:v().optional()}).describe("Defines a documentation note in text on the PCB"),TkA=xA({type:lA("pcb_note_rect"),pcb_note_rect_id:Ai("pcb_note_rect"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),text:v().optional(),center:co,width:VA,height:VA,stroke_width:VA.default("0.1mm"),corner_radius:VA.optional(),is_filled:te().optional(),has_stroke:te().optional(),is_stroke_dashed:te().optional(),color:v().optional()}).describe("Defines a rectangular documentation note on the PCB"),qkA=xA({type:lA("pcb_note_path"),pcb_note_path_id:Ai("pcb_note_path"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),text:v().optional(),route:fe(co),stroke_width:VA.default("0.1mm"),color:v().optional()}).describe("Defines a polyline documentation note on the PCB"),PkA=xA({type:lA("pcb_note_line"),pcb_note_line_id:Ai("pcb_note_line"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),text:v().optional(),x1:Ie,y1:Ie,x2:Ie,y2:Ie,stroke_width:Ie.default("0.1mm"),color:v().optional(),is_dashed:te().optional()}).describe("Defines a straight documentation note line on the PCB"),OkA=xA({type:lA("pcb_note_dimension"),pcb_note_dimension_id:Ai("pcb_note_dimension"),pcb_component_id:v().optional(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),name:v().optional(),from:co,to:co,text:v().optional(),text_ccw_rotation:NA().optional(),offset_distance:VA.optional(),offset_direction:xA({x:NA(),y:NA()}).optional(),font:lA("tscircuit2024").default("tscircuit2024"),font_size:VA.default("1mm"),color:v().optional(),arrow_size:VA.default("1mm")}).describe("Defines a measurement annotation within PCB documentation notes"),WkA=xA({type:lA("pcb_footprint_overlap_error"),pcb_error_id:Ai("pcb_error"),error_type:lA("pcb_footprint_overlap_error").default("pcb_footprint_overlap_error"),message:v(),pcb_smtpad_ids:fe(v()).optional(),pcb_plated_hole_ids:fe(v()).optional(),pcb_hole_ids:fe(v()).optional(),pcb_keepout_ids:fe(v()).optional()}).describe("Error emitted when a pcb footprint overlaps with another element"),ZkA=xA({type:lA("pcb_keepout"),shape:lA("rect"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,width:Ie,height:Ie,pcb_keepout_id:v(),layers:fe(v()),description:v().optional()}).or(xA({type:lA("pcb_keepout"),shape:lA("circle"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,radius:Ie,pcb_keepout_id:v(),layers:fe(v()),description:v().optional()})),rT=xA({type:lA("pcb_cutout"),pcb_cutout_id:Ai("pcb_cutout"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),pcb_board_id:v().optional(),pcb_panel_id:v().optional()}),VkA=rT.extend({shape:lA("rect"),center:co,width:VA,height:VA,rotation:BI.optional(),corner_radius:VA.optional()}),jkA=rT.extend({shape:lA("circle"),center:co,radius:VA}),zkA=rT.extend({shape:lA("polygon"),points:fe(co)}),XkA=rT.extend({shape:lA("path"),route:fe(co),slot_width:VA,slot_length:VA.optional(),space_between_slots:VA.optional(),slot_corner_radius:VA.optional()}),$kA=rE("shape",[VkA,jkA,zkA,XkA]).describe("Defines a cutout on the PCB, removing board material."),AGA=xA({type:lA("pcb_missing_footprint_error"),pcb_missing_footprint_error_id:Ai("pcb_missing_footprint_error"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),error_type:lA("pcb_missing_footprint_error").default("pcb_missing_footprint_error"),source_component_id:v(),message:v()}).describe("Defines a missing footprint error on the PCB"),X1=xA({type:lA("external_footprint_load_error"),external_footprint_load_error_id:Ai("external_footprint_load_error"),pcb_component_id:v(),source_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),footprinter_string:v().optional(),error_type:lA("external_footprint_load_error").default("external_footprint_load_error"),message:v()}).describe("Defines an error when an external footprint fails to load"),IX=xA({type:lA("circuit_json_footprint_load_error"),circuit_json_footprint_load_error_id:Ai("circuit_json_footprint_load_error"),pcb_component_id:v(),source_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),error_type:lA("circuit_json_footprint_load_error").default("circuit_json_footprint_load_error"),message:v(),circuit_json:fe(Yg()).optional()}).describe("Defines an error when a circuit JSON footprint fails to load"),eGA=xA({type:lA("pcb_group"),pcb_group_id:Ai("pcb_group"),source_group_id:v(),is_subcircuit:te().optional(),subcircuit_id:v().optional(),width:VA.optional(),height:VA.optional(),center:co,display_offset_x:v().optional().describe("How to display the x offset for this group, usually corresponding with how the user specified it"),display_offset_y:v().optional().describe("How to display the y offset for this group, usually corresponding with how the user specified it"),outline:fe(co).optional(),anchor_position:co.optional(),anchor_alignment:$k.default("center"),position_mode:Ze(["packed","relative_to_group_anchor","none"]).optional(),positioned_relative_to_pcb_group_id:v().optional(),positioned_relative_to_pcb_board_id:v().optional(),pcb_component_ids:fe(v()),child_layout_mode:Ze(["packed","none"]).optional(),name:v().optional(),description:v().optional(),layout_mode:v().optional(),autorouter_configuration:xA({trace_clearance:VA}).optional(),autorouter_used_string:v().optional()}).describe("Defines a group of components on the PCB"),tGA=xA({type:lA("pcb_autorouting_error"),pcb_error_id:Ai("pcb_autorouting_error"),error_type:lA("pcb_autorouting_error").default("pcb_autorouting_error"),message:v(),subcircuit_id:v().optional()}).describe("The autorouting has failed to route a portion of the board"),cX=xA({type:lA("pcb_manual_edit_conflict_warning"),pcb_manual_edit_conflict_warning_id:Ai("pcb_manual_edit_conflict_warning"),warning_type:lA("pcb_manual_edit_conflict_warning").default("pcb_manual_edit_conflict_warning"),message:v(),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),source_component_id:v()}).describe("Warning emitted when a component has both manual placement and explicit pcbX/pcbY coordinates"),iGA=xA({type:lA("pcb_breakout_point"),pcb_breakout_point_id:Ai("pcb_breakout_point"),pcb_group_id:v(),subcircuit_id:v().optional(),source_trace_id:v().optional(),source_port_id:v().optional(),source_net_id:v().optional(),x:Ie,y:Ie}).describe("Defines a routing target within a pcb_group for a source_trace or source_net"),oGA=xA({type:lA("pcb_ground_plane"),pcb_ground_plane_id:Ai("pcb_ground_plane"),source_pcb_ground_plane_id:v(),source_net_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional()}).describe("Defines a ground plane on the PCB"),nGA=xA({type:lA("pcb_ground_plane_region"),pcb_ground_plane_region_id:Ai("pcb_ground_plane_region"),pcb_ground_plane_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:ss,points:fe(co)}).describe("Defines a polygon region of a ground plane"),sGA=xA({type:lA("pcb_thermal_spoke"),pcb_thermal_spoke_id:Ai("pcb_thermal_spoke"),pcb_ground_plane_id:v(),shape:v(),spoke_count:NA(),spoke_thickness:Ie,spoke_inner_diameter:Ie,spoke_outer_diameter:Ie,pcb_plated_hole_id:v().optional(),subcircuit_id:v().optional()}).describe("Pattern for connecting a ground plane to a plated hole"),BX=xA({type:lA("pcb_copper_pour"),pcb_copper_pour_id:Ai("pcb_copper_pour"),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:ss,source_net_id:v().optional(),covered_with_solder_mask:te().optional().default(!0)}),rGA=BX.extend({shape:lA("rect"),center:co,width:VA,height:VA,rotation:BI.optional()}),aGA=BX.extend({shape:lA("brep"),brep_shape:tkA}),gGA=BX.extend({shape:lA("polygon"),points:fe(co)}),IGA=rE("shape",[rGA,aGA,gGA]).describe("Defines a copper pour on the PCB."),cGA=xA({type:lA("pcb_component_outside_board_error"),pcb_component_outside_board_error_id:Ai("pcb_component_outside_board_error"),error_type:lA("pcb_component_outside_board_error").default("pcb_component_outside_board_error"),message:v(),pcb_component_id:v(),pcb_board_id:v(),component_center:co,component_bounds:xA({min_x:NA(),max_x:NA(),min_y:NA(),max_y:NA()}),subcircuit_id:v().optional(),source_component_id:v().optional()}).describe("Error emitted when a PCB component is placed outside the board boundaries"),aT=xA({type:lA("pcb_component_invalid_layer_error"),pcb_component_invalid_layer_error_id:Ai("pcb_component_invalid_layer_error"),error_type:lA("pcb_component_invalid_layer_error").default("pcb_component_invalid_layer_error"),message:v(),pcb_component_id:v().optional(),source_component_id:v(),layer:ss,subcircuit_id:v().optional()}).describe("Error emitted when a component is placed on an invalid layer (components can only be on 'top' or 'bottom' layers)"),BGA=xA({type:lA("pcb_via_clearance_error"),pcb_error_id:Ai("pcb_error"),error_type:lA("pcb_via_clearance_error").default("pcb_via_clearance_error"),message:v(),pcb_via_ids:fe(v()).min(2),minimum_clearance:Ie.optional(),actual_clearance:Ie.optional(),pcb_center:xA({x:NA().optional(),y:NA().optional()}).optional(),subcircuit_id:v().optional()}).describe("Error emitted when vias are closer than the allowed clearance"),CGA=xA({type:lA("pcb_courtyard_rect"),pcb_courtyard_rect_id:Ai("pcb_courtyard_rect"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),center:co,width:VA,height:VA,layer:sm,color:v().optional()}).describe("Defines a courtyard rectangle on the PCB"),lGA=xA({type:lA("pcb_courtyard_outline"),pcb_courtyard_outline_id:Ai("pcb_courtyard_outline"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:sm,outline:fe(co).min(2),stroke_width:VA.default("0.1mm"),is_closed:te().optional(),is_stroke_dashed:te().optional(),color:v().optional()}).describe("Defines a courtyard outline on the PCB"),QGA=xA({type:lA("pcb_courtyard_polygon"),pcb_courtyard_polygon_id:Ai("pcb_courtyard_polygon"),pcb_component_id:v(),pcb_group_id:v().optional(),subcircuit_id:v().optional(),layer:sm,points:fe(co).min(3),color:v().optional()}).describe("Defines a courtyard polygon on the PCB"),EGA=xA({type:lA("cad_component"),cad_component_id:v(),pcb_component_id:v(),source_component_id:v(),position:IR,rotation:IR.optional(),size:IR.optional(),layer:ss.optional(),subcircuit_id:v().optional(),footprinter_string:v().optional(),model_obj_url:v().optional(),model_stl_url:v().optional(),model_3mf_url:v().optional(),model_gltf_url:v().optional(),model_glb_url:v().optional(),model_step_url:v().optional(),model_wrl_url:v().optional(),model_unit_to_mm_scale_factor:NA().optional(),model_jscad:Yg().optional(),show_as_translucent_model:te().optional()}).describe("Defines a component on the PCB"),hGA=Ze(["sinewave","square","triangle","sawtooth"]),Tbe=Zt([v(),NA()]).transform(t=>typeof t=="string"?t.endsWith("%")?parseFloat(t.slice(0,-1))/100:parseFloat(t):t).pipe(NA().min(0,"Duty cycle must be non-negative").max(1,"Duty cycle cannot be greater than 100%")),uGA=xA({type:lA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:lA(!0).optional().default(!0),positive_source_port_id:v().optional(),negative_source_port_id:v().optional(),positive_source_net_id:v().optional(),negative_source_net_id:v().optional(),voltage:z0}).describe("Defines a DC voltage source for simulation"),dGA=xA({type:lA("simulation_voltage_source"),simulation_voltage_source_id:Ai("simulation_voltage_source"),is_dc_source:lA(!1),terminal1_source_port_id:v().optional(),terminal2_source_port_id:v().optional(),terminal1_source_net_id:v().optional(),terminal2_source_net_id:v().optional(),voltage:z0.optional(),frequency:HD.optional(),peak_to_peak_voltage:z0.optional(),wave_shape:hGA.optional(),phase:BI.optional(),duty_cycle:Tbe.optional()}).describe("Defines an AC voltage source for simulation"),pGA=Zt([uGA,dGA]).describe("Defines a voltage source for simulation"),fGA=Zt([lA("spice_dc_sweep"),lA("spice_dc_operating_point"),lA("spice_transient_analysis"),lA("spice_ac_analysis")]),yGA=xA({type:lA("simulation_experiment"),simulation_experiment_id:Ai("simulation_experiment"),name:v(),experiment_type:fGA,time_per_step:j1.optional(),start_time_ms:Tf.optional(),end_time_ms:Tf.optional()}).describe("Defines a simulation experiment configuration"),mGA=xA({type:lA("simulation_transient_voltage_graph"),simulation_transient_voltage_graph_id:Ai("simulation_transient_voltage_graph"),simulation_experiment_id:v(),timestamps_ms:fe(NA()).optional(),voltage_levels:fe(NA()),source_component_id:v().optional(),subcircuit_connectivity_map_key:v().optional(),time_per_step:j1,start_time_ms:Tf,end_time_ms:Tf,name:v().optional(),color:v().optional()}).describe("Stores voltage measurements over time for a simulation"),wGA=xA({type:lA("simulation_switch"),simulation_switch_id:Ai("simulation_switch"),source_component_id:v().optional(),closes_at:Tf.optional(),opens_at:Tf.optional(),starts_closed:te().optional(),switching_frequency:HD.optional()}).describe("Defines a switch for simulation timing control"),DGA=xA({type:lA("simulation_voltage_probe"),simulation_voltage_probe_id:Ai("simulation_voltage_probe"),source_component_id:v().optional(),name:v().optional(),signal_input_source_port_id:v().optional(),signal_input_source_net_id:v().optional(),reference_input_source_port_id:v().optional(),reference_input_source_net_id:v().optional(),subcircuit_id:v().optional(),color:v().optional()}).describe("Defines a voltage probe for simulation. If a reference input is not provided, it measures against ground. If a reference input is provided, it measures the differential voltage between two points.").superRefine((t,A)=>{if(t.reference_input_source_port_id||t.reference_input_source_net_id){const i=!!t.signal_input_source_port_id||!!t.reference_input_source_port_id,o=!!t.signal_input_source_net_id||!!t.reference_input_source_net_id;i&&o?A.addIssue({code:Wt.custom,message:"Cannot mix port and net connections in a differential probe."}):i?(!t.signal_input_source_port_id||!t.reference_input_source_port_id)&&A.addIssue({code:Wt.custom,message:"Differential port probe requires both signal_input_source_port_id and reference_input_source_port_id."}):o&&(!t.signal_input_source_net_id||!t.reference_input_source_net_id)&&A.addIssue({code:Wt.custom,message:"Differential net probe requires both signal_input_source_net_id and reference_input_source_net_id."})}else!!t.signal_input_source_port_id==!!t.signal_input_source_net_id&&A.addIssue({code:Wt.custom,message:"A voltage probe must have exactly one of signal_input_source_port_id or signal_input_source_net_id."})}),SGA=xA({type:lA("simulation_unknown_experiment_error"),simulation_unknown_experiment_error_id:Ai("simulation_unknown_experiment_error"),error_type:lA("simulation_unknown_experiment_error").default("simulation_unknown_experiment_error"),message:v(),simulation_experiment_id:v().optional(),subcircuit_id:v().optional()}).describe("An unknown error occurred during the simulation experiment."),bGA=Zt([yxA,pxA,fxA,dxA,wxA,mxA,Tz,Yz,nT,Kz,Jz,qz,Pz,Oz,Vz,jz,zz,eX,Xz,$z,AX,Zz,Wz,SxA,bxA,DxA,tX,iX,oX,xxA,sX,okA,ckA,AGA,X1,IX,cX,BkA,ZkA,CkA,DkA,hkA,pkA,SkA,QkA,EkA,bkA,xkA,eGA,GkA,FkA,_kA,RkA,NkA,MkA,vkA,UkA,fkA,ykA,kkA,mkA,wkA,BGA,HkA,LkA,YkA,JkA,KkA,TkA,qkA,PkA,OkA,tGA,WkA,iGA,$kA,oGA,nGA,sGA,IGA,cGA,aT,CGA,lGA,QGA,kxA,JxA,vxA,UxA,LxA,HxA,MxA,KxA,YxA,GxA,qxA,PxA,TxA,VxA,jxA,rX,zxA,AkA,XxA,$xA,EGA,pGA,yGA,mGA,wGA,DGA,SGA]),cR=bGA;const $1=Object.freeze(Object.defineProperty({__proto__:null,all_layers:z1,any_circuit_element:bGA,any_soup_element:cR,any_source_component:dxA,battery_capacity:IxA,brep_shape:tkA,cad_component:EGA,capacitance:gR,circuit_json_footprint_load_error:IX,current:Cbe,distance:Ie,duration_ms:j1,experiment_type:fGA,external_footprint_load_error:X1,frequency:HD,getZodPrefixedIdWithDefault:Ai,inductance:Lz,layer_ref:ss,layer_string:nX,length:VA,ms:Tf,ninePointAnchor:$k,pcb_autorouting_error:tGA,pcb_board:bkA,pcb_breakout_point:iGA,pcb_component:okA,pcb_component_invalid_layer_error:aT,pcb_component_outside_board_error:cGA,pcb_copper_pour:IGA,pcb_copper_pour_brep:aGA,pcb_copper_pour_polygon:gGA,pcb_copper_pour_rect:rGA,pcb_copper_text:NkA,pcb_courtyard_outline:lGA,pcb_courtyard_polygon:QGA,pcb_courtyard_rect:CGA,pcb_cutout:$kA,pcb_cutout_circle:jkA,pcb_cutout_path:XkA,pcb_cutout_polygon:zkA,pcb_cutout_rect:VkA,pcb_fabrication_note_dimension:JkA,pcb_fabrication_note_path:HkA,pcb_fabrication_note_rect:YkA,pcb_fabrication_note_text:LkA,pcb_footprint_overlap_error:WkA,pcb_ground_plane:oGA,pcb_ground_plane_region:nGA,pcb_group:eGA,pcb_hole:ckA,pcb_hole_circle_or_square_shape:mbe,pcb_hole_circle_shape:fbe,pcb_hole_oval_shape:wbe,pcb_hole_pill_shape:Dbe,pcb_hole_rect_shape:ybe,pcb_hole_rotated_pill_shape:Sbe,pcb_keepout:ZkA,pcb_manual_edit_conflict_warning:cX,pcb_missing_footprint_error:AGA,pcb_net:DkA,pcb_note_dimension:OkA,pcb_note_line:PkA,pcb_note_path:qkA,pcb_note_rect:TkA,pcb_note_text:KkA,pcb_panel:xkA,pcb_placement_error:kkA,pcb_plated_hole:BkA,pcb_port:CkA,pcb_port_not_connected_error:wkA,pcb_port_not_matched_error:mkA,pcb_route_hint:ikA,pcb_route_hints:pbe,pcb_silkscreen_circle:vkA,pcb_silkscreen_line:FkA,pcb_silkscreen_oval:UkA,pcb_silkscreen_path:_kA,pcb_silkscreen_rect:MkA,pcb_silkscreen_text:RkA,pcb_smtpad:QkA,pcb_smtpad_pill:lkA,pcb_solder_paste:EkA,pcb_text:hkA,pcb_thermal_spoke:sGA,pcb_trace:pkA,pcb_trace_error:fkA,pcb_trace_hint:GkA,pcb_trace_missing_error:ykA,pcb_trace_route_point:gX,pcb_trace_route_point_via:dkA,pcb_trace_route_point_wire:ukA,pcb_via:SkA,pcb_via_clearance_error:BGA,point:co,point3:IR,point_with_bulge:ekA,port_arrangement:NxA,position:Qbe,position3:Ebe,resistance:aR,ring:aX,rotation:BI,route_hint_point:sw,schematic_arc:HxA,schematic_box:kxA,schematic_circle:LxA,schematic_component:MxA,schematic_component_port_arrangement_by_sides:RxA,schematic_component_port_arrangement_by_size:_xA,schematic_debug_line:WxA,schematic_debug_object:VxA,schematic_debug_object_base:sT,schematic_debug_point:ZxA,schematic_debug_rect:OxA,schematic_error:qxA,schematic_group:zxA,schematic_layout_error:PxA,schematic_line:vxA,schematic_manual_edit_conflict_warning:rX,schematic_net_label:TxA,schematic_path:GxA,schematic_pin_styles:FxA,schematic_port:KxA,schematic_rect:UxA,schematic_sheet:AkA,schematic_table:XxA,schematic_table_cell:$xA,schematic_text:JxA,schematic_trace:YxA,schematic_voltage_probe:jxA,simulation_ac_voltage_source:dGA,simulation_dc_voltage_source:uGA,simulation_experiment:yGA,simulation_switch:wGA,simulation_transient_voltage_graph:mGA,simulation_unknown_experiment_error:SGA,simulation_voltage_probe:DGA,simulation_voltage_source:pGA,size:Hz,source_board:DxA,source_component_base:dB,source_component_internal_connection:fxA,source_failed_to_create_component_error:QxA,source_group:mxA,source_interconnect:uxA,source_manually_placed_via:bxA,source_missing_property_error:lxA,source_net:wxA,source_pcb_ground_plane:SxA,source_pin_missing_trace_warning:oX,source_pin_must_be_connected_error:xxA,source_port:pxA,source_project_metadata:tX,source_property_ignored_warning:ExA,source_simple_battery:Pz,source_simple_capacitor:Yz,source_simple_chip:Tz,source_simple_crystal:CxA,source_simple_diode:nT,source_simple_fiducial:cxA,source_simple_ground:BxA,source_simple_inductor:Oz,source_simple_led:Kz,source_simple_mosfet:AX,source_simple_pin_header:Vz,source_simple_pinout:jz,source_simple_potentiometer:Zz,source_simple_power_source:qz,source_simple_push_button:Wz,source_simple_resistor:Jz,source_simple_resonator:zz,source_simple_switch:eX,source_simple_test_point:$z,source_simple_transistor:Xz,source_simple_voltage_probe:hxA,source_trace:yxA,source_trace_not_connected_error:iX,supplier_name:oT,time:lbe,timestamp:gxA,unknown_error_finding_part:sX,visible_layer:sm,voltage:z0,wave_shape:hGA},Symbol.toStringTag,{value:"Module"}));function ge(t,A){return Array.isArray(A)?[t.a*A[0]+t.c*A[1]+t.e,t.b*A[0]+t.d*A[1]+t.f]:{x:t.a*A.x+t.c*A.y+t.e,y:t.b*A.x+t.d*A.y+t.f}}function qbe(t,A){return A.map(e=>ge(t,e))}function xGA(t){return{a:parseFloat(t.a),b:parseFloat(t.b),c:parseFloat(t.c),d:parseFloat(t.d),e:parseFloat(t.e),f:parseFloat(t.f)}}const Pbe=/^matrix\(\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*,\s*([0-9_+-.e]+)\s*\)$/i;function gT(t){const A=t.match(Pbe);if(A===null||A.length<7)throw new Error(`'${t}' is not a matrix`);return{a:parseFloat(A[1]),b:parseFloat(A[2]),c:parseFloat(A[3]),d:parseFloat(A[4]),e:parseFloat(A[5]),f:parseFloat(A[6])}}function pg(){return{a:1,c:0,e:0,b:0,d:1,f:0}}function X0(t){const{a:A,b:e,c:i,d:o,e:n,f:s}=t,r=A*o-e*i;return{a:o/r,b:e/-r,c:i/-r,d:A/r,e:(o*n-i*s)/-r,f:(e*n-A*s)/r}}function A2(t){return typeof t>"u"}function BR(t){return typeof t=="number"&&!Number.isNaN(t)&&Number.isFinite(t)}function Obe(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Wbe(t){return Obe(t)&&"a"in t&&BR(t.a)&&"b"in t&&BR(t.b)&&"c"in t&&BR(t.c)&&"d"in t&&BR(t.d)&&"e"in t&&BR(t.e)&&"f"in t&&BR(t.f)}function Wi(t,A=0){return{a:1,c:0,e:t,b:0,d:1,f:A}}function CR(...t){t=Array.isArray(t[0])?t[0]:t;const A=(e,i)=>({a:e.a*i.a+e.c*i.b,c:e.a*i.c+e.c*i.d,e:e.a*i.e+e.c*i.f+e.e,b:e.b*i.a+e.d*i.b,d:e.b*i.c+e.d*i.d,f:e.b*i.e+e.d*i.f+e.f});switch(t.length){case 0:throw new Error("no matrices provided");case 1:return t[0];case 2:return A(t[0],t[1]);default:{const[e,i,...o]=t,n=A(e,i);return CR(n,...o)}}}function Ji(...t){return CR(...t)}const{cos:Zbe,sin:Vbe,PI:jbe}=Math;function YI(t,A,e){const i=Zbe(t),o=Vbe(t),n={a:i,c:-o,e:0,b:o,d:i,f:0};return A2(A)||A2(e)?n:CR([Wi(A,e),n,Wi(-A,-e)])}function e2(t,A=void 0,e=void 0){return YI(t*jbe/180,A,e)}function ya(t,A=void 0,e=void 0,i=void 0){A2(A)&&(A=t);const o={a:t,c:0,e:0,b:0,d:A,f:0};return A2(e)||A2(i)?o:CR([Wi(e,i),o,Wi(-e,-i)])}function kGA(t,A){return{a:1,c:t,e:0,b:A,d:1,f:0}}const{tan:GGA}=Math;function FGA(t,A){return{a:1,c:GGA(t),e:0,b:GGA(A),d:1,f:0}}function CX(t,A){return FGA(t*Math.PI/180,A*Math.PI/180)}function zbe(t){return fu(t)}function _GA(t){return fu(t)}function fu(t){return`matrix(${t.a},${t.b},${t.c},${t.d},${t.e},${t.f})`}function RGA(t,A=1e10){return{a:Math.round(t.a*A)/A,b:Math.round(t.b*A)/A,c:Math.round(t.c*A)/A,d:Math.round(t.d*A)/A,e:Math.round(t.e*A)/A,f:Math.round(t.f*A)/A}}function NGA(t,A){const e=t[0].x!=null?t[0].x:t[0][0],i=t[0].y!=null?t[0].y:t[0][1],o=A[0].x!=null?A[0].x:A[0][0],n=A[0].y!=null?A[0].y:A[0][1],s=t[1].x!=null?t[1].x:t[1][0],r=t[1].y!=null?t[1].y:t[1][1],a=A[1].x!=null?A[1].x:A[1][0],g=A[1].y!=null?A[1].y:A[1][1],I=t[2].x!=null?t[2].x:t[2][0],c=t[2].y!=null?t[2].y:t[2][1],B=A[2].x!=null?A[2].x:A[2][0],C=A[2].y!=null?A[2].y:A[2][1],l={a:e-I,b:i-c,c:s-I,d:r-c,e:I,f:c},Q={a:o-B,b:n-C,c:a-B,d:g-C,e:B,f:C},E=X0(l),h=CR([Q,E]);return RGA(h)}function Xbe(t){return Array.isArray(t)?t.map(A):A(t);function A(e){switch(e.type){case"matrix":if("a"in e&&"b"in e&&"c"in e&&"d"in e&&"e"in e&&"f"in e)return xGA(e);throw new Error("MISSING_MANDATORY_PARAM");case"translate":if(!("tx"in e))throw new Error("MISSING_MANDATORY_PARAM");return"ty"in e?Wi(e.tx,e.ty):Wi(e.tx);case"scale":if(!("sx"in e))throw new Error("MISSING_MANDATORY_PARAM");return"sy"in e?ya(e.sx,e.sy):ya(e.sx);case"rotate":if(!("angle"in e))throw new Error("MISSING_MANDATORY_PARAM");return"cx"in e&&"cy"in e?e2(e.angle,e.cx,e.cy):e2(e.angle);case"skewX":if(!("angle"in e))throw new Error("MISSING_MANDATORY_PARAM");return CX(e.angle,0);case"skewY":if(!("angle"in e))throw new Error("MISSING_MANDATORY_PARAM");return CX(0,e.angle);case"shear":if(!("shx"in e&&"shy"in e))throw new Error("MISSING_MANDATORY_PARAM");return kGA(e.shx,e.shy);default:throw new Error("UNSUPPORTED_DESCRIPTOR")}}}function $be(t,A){function e(){this.constructor=t}e.prototype=A.prototype,t.prototype=new e}function lR(t,A,e,i){var o=Error.call(this,t);return Object.setPrototypeOf&&Object.setPrototypeOf(o,lR.prototype),o.expected=A,o.found=e,o.location=i,o.name="SyntaxError",o}$be(lR,Error);function lX(t,A,e){return e=e||" ",t.length>A?t:(A-=t.length,e+=e.repeat(A),t+e.slice(0,A))}lR.prototype.format=function(t){var A="Error: "+this.message;if(this.location){var e=null,i;for(i=0;i<t.length;i++)if(t[i].source===this.location.source){e=t[i].text.split(/\r\n|\n|\r/g);break}var o=this.location.start,n=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(o):o,s=this.location.source+":"+n.line+":"+n.column;if(e){var r=this.location.end,a=lX("",n.line.toString().length," "),g=e[o.line-1],I=o.line===r.line?r.column:g.length+1,c=I-o.column||1;A+=`
|
|
4040
4040
|
--> `+s+`
|
|
4041
4041
|
`+a+` |
|
|
4042
4042
|
`+n.line+" | "+g+`
|
|
@@ -5598,7 +5598,7 @@ test("${g} should solve problem correctly", () => {
|
|
|
5598
5598
|
// Add more specific assertions based on expected output
|
|
5599
5599
|
// expect(solver.netLabelPlacementSolver!.netLabelPlacements).toMatchInlineSnapshot()
|
|
5600
5600
|
})
|
|
5601
|
-
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},pie=t=>t.activeSubSolver?[t,...pie(t.activeSubSolver)]:[t],sHt=({solver:t})=>{const A=pie(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(nHt,{solver:e})]},e.constructor.name))})},rHt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(sHt,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},aHt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},gHt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=aHt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},IHt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},cHt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},BHt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),CHt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=BHt(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},SEA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(SEA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=SEA(i));return A},lHt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=SEA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},QHt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>gHt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):lHt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(IHt,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(cHt,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(CHt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},EHt=class extends Ao.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function hHt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>V.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var uHt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(rHt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(EHt,{fallback:V.jsx(hHt,{graphics:s}),children:V.jsx(oHt,{graphics:s})}),a&&V.jsx(QHt,{solver:t,onStepUntilPhase:g})]})};const dHt=()=>{AA.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},pHt=t=>t.toLowerCase().includes("pack")?Dmt:t.toLowerCase().includes("rout")?Gmt:Emt,fHt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);dHt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=OHA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(OHA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=pHt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(cS,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(uHt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},fie=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{OJ.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{OJ.captureException(o,{error_type:i.type})}catch{}}},[e])},yie="0.0.1420",yHt={version:yie},bEA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},xEA=new Map,CW=t=>{const A=xEA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},mHt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=xEA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return xEA.set(e.name,o),{type:"tracked",store:t,...o}},mie=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(bEA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(bEA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=mHt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...CW(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(bEA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return kEA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5601
|
+
`,c=new Blob([I],{type:"text/plain"}),B=URL.createObjectURL(c),C=document.createElement("a");C.href=B,C.download=`${g}.test.ts`,C.click(),URL.revokeObjectURL(B)}catch(a){alert(`Error generating test.ts for ${t.constructor.name}: ${a instanceof Error?a.message:String(a)}`)}i(!1)};return V.jsxs("div",{className:`relative ${A}`,ref:o,children:[V.jsx("button",{className:"px-2 py-1 rounded text-xs cursor-pointer",onClick:()=>i(!e),title:`Download options for ${t.constructor.name}`,children:t.constructor.name}),e&&V.jsxs("div",{className:"absolute top-full left-0 mt-1 bg-white border border-gray-300 rounded shadow-lg z-10 min-w-[150px]",children:[V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:n,children:"Download JSON"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:s,children:"Download page.tsx"}),V.jsx("button",{className:"w-full text-left px-3 py-2 hover:bg-gray-100 text-xs",onClick:r,children:"Download test.ts"})]})]})},pie=t=>t.activeSubSolver?[t,...pie(t.activeSubSolver)]:[t],sHt=({solver:t})=>{const A=pie(t);return V.jsx("div",{className:"flex gap-1 items-center text-sm pt-1",children:A.map((e,i)=>V.jsxs("div",{className:"flex items-center",children:[i>0&&V.jsx("span",{className:"text-gray-400 mx-1",children:"→"}),V.jsx(nHt,{solver:e})]},e.constructor.name))})},rHt=({solver:t,triggerRender:A,animationSpeed:e=25,onSolverStarted:i,onSolverCompleted:o})=>{const[n,s]=AA.useReducer(Q=>!Q,!1),r=AA.useRef(void 0),a=()=>{!t.solved&&!t.failed&&(t.step(),A())},g=()=>{!t.solved&&!t.failed&&(i&&i(t),t.solve(),A(),o&&o(t))},I=()=>{n?(r.current&&(clearInterval(r.current),r.current=void 0),s()):(s(),r.current=setInterval(()=>{if(t.solved||t.failed){r.current&&(clearInterval(r.current),r.current=void 0),s(),A(),o&&t.solved&&o(t);return}t.step(),A()},e))},c=()=>{const Q=t;if(Q.getCurrentPhase&&!t.solved&&!t.failed){const E=Q.getCurrentPhase();for(;Q.getCurrentPhase()===E&&!t.solved&&!t.failed;)t.step();A()}},B=()=>{if(t.solved||t.failed||n)return;const Q=window.prompt("Step until which iteration?",`${t.iterations}`);if(Q===null)return;const E=Number(Q);if(!Number.isFinite(E)){window.alert("Please enter a valid number for the iteration");return}for(;t.iterations<E&&!t.solved&&!t.failed;)t.step();A(),t.solved&&o&&o(t)};AA.useEffect(()=>()=>{r.current&&clearInterval(r.current)},[]),AA.useEffect(()=>{(t.solved||t.failed)&&n&&(r.current&&(clearInterval(r.current),r.current=void 0),s())},[t.solved,t.failed,n]);const C=t.getCurrentPhase!==void 0,l=C?t.getCurrentPhase():null;return V.jsxs("div",{className:"space-y-2 p-2 border-b",children:[V.jsx("div",{className:"flex items-center",children:V.jsx(sHt,{solver:t})}),V.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[V.jsx("button",{onClick:a,disabled:t.solved||t.failed||n,className:"bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step"}),V.jsx("button",{onClick:g,disabled:t.solved||t.failed||n,className:"bg-green-500 hover:bg-green-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Solve"}),V.jsx("button",{onClick:I,disabled:t.solved||t.failed,className:`px-3 py-1 rounded text-white text-sm ${n?"bg-red-500 hover:bg-red-600":"bg-yellow-500 hover:bg-yellow-600"} disabled:bg-gray-300`,children:n?"Stop":"Animate"}),V.jsx("button",{onClick:B,disabled:t.solved||t.failed||n,className:"bg-orange-500 hover:bg-orange-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Step Until Iteration"}),C&&V.jsx("button",{onClick:c,disabled:t.solved||t.failed||n,className:"bg-purple-500 hover:bg-purple-600 disabled:bg-gray-300 text-white px-3 py-1 rounded text-sm",children:"Next Stage"}),V.jsxs("div",{className:"text-sm text-gray-600",children:["Iterations: ",t.iterations]}),t.timeToSolve!==void 0&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Time: ",(t.timeToSolve/1e3).toFixed(3),"s"]}),l&&V.jsxs("div",{className:"text-sm text-gray-600",children:["Phase: ",V.jsx("span",{className:"font-medium",children:l})]}),t.solved&&V.jsx("div",{className:"px-2 py-1 bg-green-100 text-green-800 rounded text-sm",children:"Solved"}),t.failed&&V.jsx("div",{className:"px-2 py-1 bg-red-100 text-red-800 rounded text-sm",children:"Failed"})]}),t.error&&V.jsxs("div",{className:"text-red-600 text-sm",children:["Error: ",t.error]})]})},aHt=(t,A,e)=>{const i=t.currentPipelineStepIndex;return A<i?"Completed":A===i&&t.activeSubSolver?t.activeSubSolver.failed?"Failed":"In Progress":"Not Started"},gHt=(t,A)=>{const i=t.pipelineDef[A].solverName,o=aHt(t,A),n=t[i],s=t.firstIterationOfPhase?.[i]??null,r=t.iterations;let a=0;if(o==="Completed"){const B=t.pipelineDef[A+1],C=B?t.firstIterationOfPhase?.[B.solverName]:void 0;C!==void 0&&s!==null?a=C-s:s!==null&&(a=r-s)}else o==="In Progress"&&s!==null&&(a=r-s);const g=t.timeSpentOnPhase?.[i]??0;let I=0;o==="Completed"?I=1:o==="In Progress"&&n&&(I=n.progress??0);const c=n?.stats??null;return{index:A,name:i,status:o,firstIteration:s,iterations:a,progress:I,timeSpent:g,stats:c&&Object.keys(c).length>0?c:null,solverInstance:n??null}},IHt=({status:t})=>{const A={"Not Started":"text-blue-600","In Progress":"text-yellow-600",Completed:"text-green-600",Failed:"text-red-600"};return V.jsx("span",{className:`font-medium ${A[t]}`,children:t})},cHt=({progress:t})=>{if(t===0)return null;const A=Math.round(t*100);return V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("div",{className:"w-20 h-2 bg-gray-200 rounded overflow-hidden",children:V.jsx("div",{className:"h-full bg-blue-500 transition-all duration-200",style:{width:`${A}%`}})}),V.jsxs("span",{className:"text-xs text-gray-500",children:[A,"%"]})]})},BHt=t=>Object.entries(t).map(([A,e])=>`${A}: ${e}`).join(", "),CHt=({stats:t})=>{if(!t||Object.keys(t).length===0)return V.jsx("span",{children:"-"});const A=Object.entries(t),e=BHt(t);return V.jsxs("details",{className:"cursor-pointer",children:[V.jsx("summary",{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[200px]",children:e}),V.jsx("div",{className:"mt-1 text-xs",children:A.map(([i,o])=>V.jsxs("div",{children:[i,": ",String(o)]},i))})]})},SEA=t=>{if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(SEA);const A={};for(const[e,i]of Object.entries(t))e.startsWith("_")||(A[e]=SEA(i));return A},lHt=(t,A)=>{try{if(typeof t.getConstructorParams!="function"){alert(`getConstructorParams() is not implemented for ${A}`);return}const e=SEA(t.getConstructorParams()),i=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),o=URL.createObjectURL(i),n=document.createElement("a");n.href=o,n.download=`${A}_input.json`,n.click(),URL.revokeObjectURL(o)}catch(e){alert(`Error downloading input for ${A}: ${e instanceof Error?e.message:String(e)}`)}},QHt=({solver:t,onStepUntilPhase:A,onDownloadInput:e})=>{const i=t.pipelineDef.map((r,a)=>gHt(t,a)),o=r=>{A?.(r)},n=r=>{r.solverInstance&&(e?e(r.solverInstance,r.name):lHt(r.solverInstance,r.name))},s=r=>`${(r/1e3).toFixed(2)}s`;return V.jsxs("div",{className:"border-t border-gray-200",children:[V.jsx("div",{className:"px-4 py-2 bg-gray-50 border-b border-gray-200",children:V.jsx("h3",{className:"text-sm font-semibold text-gray-700",children:"Pipeline Steps"})}),V.jsx("div",{className:"overflow-x-auto",children:V.jsxs("table",{className:"w-full text-sm",children:[V.jsx("thead",{children:V.jsxs("tr",{className:"bg-gray-50 border-b border-gray-200",children:[V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Step"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Status"}),V.jsxs("th",{className:"px-4 py-2 text-center font-semibold text-gray-700",children:["i",V.jsx("sub",{children:"0"})]}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Iterations"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Progress"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Time"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Stats"}),V.jsx("th",{className:"px-4 py-2 text-left font-semibold text-gray-700",children:"Input"})]})}),V.jsx("tbody",{children:i.map(r=>V.jsxs("tr",{className:`border-b border-gray-100 ${r.status==="In Progress"?"bg-yellow-50":""}`,children:[V.jsx("td",{className:"px-4 py-2",children:V.jsxs("div",{className:"flex items-center gap-2",children:[V.jsx("span",{className:"text-gray-400 w-6",children:String(r.index+1).padStart(2,"0")}),V.jsx("button",{onClick:()=>o(r.name),disabled:r.status==="Completed"||t.solved||t.failed,className:"text-blue-500 hover:text-blue-700 disabled:text-gray-300 disabled:cursor-not-allowed",title:`Step until ${r.name} completes`,children:V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M4.5 5.653c0-1.426 1.529-2.33 2.779-1.643l11.54 6.348c1.295.712 1.295 2.573 0 3.285L7.28 19.991c-1.25.687-2.779-.217-2.779-1.643V5.653z",clipRule:"evenodd"})})}),V.jsx("span",{className:"font-medium text-gray-900",children:r.name})]})}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(IHt,{status:r.status})}),V.jsx("td",{className:"px-4 py-2 text-center text-gray-600",children:r.firstIteration!==null?r.firstIteration:""}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:r.iterations}),V.jsx("td",{className:"px-4 py-2",children:V.jsx(cHt,{progress:r.progress})}),V.jsx("td",{className:"px-4 py-2 text-gray-600",children:s(r.timeSpent)}),V.jsx("td",{className:"px-4 py-2 text-gray-500",children:V.jsx(CHt,{stats:r.stats})}),V.jsx("td",{className:"px-4 py-2",children:r.solverInstance?V.jsxs("button",{onClick:()=>n(r),className:"flex items-center gap-1 text-blue-500 hover:text-blue-700",title:`Download input for ${r.name}`,children:[V.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:V.jsx("path",{fillRule:"evenodd",d:"M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z",clipRule:"evenodd"})}),V.jsx("span",{children:"Input"})]}):null})]},r.name))})]})})]})},EHt=class extends Ao.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error("InteractiveGraphics render error:",t)}render(){return this.state.hasError?this.props.fallback:this.props.children}};function hHt({graphics:t}){const A=t.points??[],e=t.lines??[],i=t.rects??[],o=t.circles??[],n=t.texts??[];let s=Number.POSITIVE_INFINITY,r=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;const I=(E,h)=>{typeof E=="number"&&(E<s&&(s=E),E>a&&(a=E)),typeof h=="number"&&(h<r&&(r=h),h>g&&(g=h))};for(const E of A)I(E.x,E.y);for(const E of e){const h=E.points??[];for(const u of h)I(u.x,u.y)}for(const E of i){const h=E.x??0,u=E.y??0,d=E.width??0,f=E.height??0;I(h,u),I(h+d,u+f)}for(const E of o){const h=E.x??0,u=E.y??0,d=E.radius??1;I(h-d,u-d),I(h+d,u+d)}for(const E of n)I(E.x,E.y);(!isFinite(s)||!isFinite(r)||!isFinite(a)||!isFinite(g))&&(s=-20,r=-20,a=20,g=20);const c=10,B=s-c,C=r-c,l=Math.max(1,a-s+2*c),Q=Math.max(1,g-r+2*c);return V.jsxs("svg",{className:"w-full h-[400px] bg-white",viewBox:`${B} ${C} ${l} ${Q}`,role:"img","aria-label":"Graphics fallback",children:[i.map((E,h)=>V.jsx("rect",{x:E.x??0,y:E.y??0,width:E.width??0,height:E.height??0,fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`rect-${h}`)),e.map((E,h)=>V.jsx("polyline",{fill:"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1,points:(E.points??[]).map(u=>`${u.x??0},${u.y??0}`).join(" ")},`line-${h}`)),o.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.fillColor??"none",stroke:E.strokeColor??"black",strokeWidth:E.strokeWidth??1},`circle-${h}`)),A.map((E,h)=>V.jsx("circle",{cx:E.x??0,cy:E.y??0,r:E.radius??1.5,fill:E.color??"black"},`point-${h}`)),n.map((E,h)=>V.jsx("text",{x:E.x??0,y:E.y??0,fontSize:E.fontSize??10,fill:E.color??"black",children:E.text??""},`text-${h}`))]})}var uHt=({solver:t,animationSpeed:A=25,onSolverStarted:e,onSolverCompleted:i})=>{const[o,n]=AA.useReducer(I=>I+1,0),s=AA.useMemo(()=>{try{return t.visualize()||{points:[],lines:[],rects:[],circles:[]}}catch(I){return console.error("Visualization error:",I),{points:[],lines:[],rects:[],circles:[]}}},[t,o]),r=AA.useMemo(()=>(s.rects?.length||0)===0&&(s.lines?.length||0)===0&&(s.points?.length||0)===0&&(s.circles?.length||0)===0,[s]);AA.useEffect(()=>{if(!(typeof document>"u")&&!document.querySelector('script[src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"]')){const I=document.createElement("script");I.src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",document.head.appendChild(I)}},[]);const a=t.pipelineDef!==void 0,g=I=>{const c=t;if(!t.solved&&!t.failed){for(;!t.solved&&!t.failed&&c.currentPipelineStepIndex<=c.pipelineDef.findIndex(B=>B.solverName===I);)t.step();n()}};return V.jsxs("div",{children:[V.jsx(rHt,{solver:t,triggerRender:n,animationSpeed:A,onSolverStarted:e,onSolverCompleted:i}),r?V.jsx("div",{className:"p-4 text-gray-500",children:"No Graphics Yet"}):V.jsx(EHt,{fallback:V.jsx(hHt,{graphics:s}),children:V.jsx(oHt,{graphics:s})}),a&&V.jsx(QHt,{solver:t,onStepUntilPhase:g})]})};const dHt=()=>{AA.useEffect(()=>{const t="tailwind-cdn-script";if(document.getElementById(t)||window.tailwind)return;const A=document.createElement("div");A.className="hidden",document.body.appendChild(A);const e=window.getComputedStyle(A).display==="none";if(document.body.removeChild(A),e)return;const i=document.createElement("script");i.id=t,i.src="https://cdn.tailwindcss.com",document.head.appendChild(i)},[])},pHt=t=>t.toLowerCase().includes("pack")?Dmt:t.toLowerCase().includes("rout")?Gmt:Emt,fHt=({solverEvents:t=[]})=>{const[A,e]=AA.useState(null);dHt();const i=AA.useMemo(()=>{const r=new Map;for(const a of t){const g=`${a.componentName}-${a.solverName}`;r.set(g,a)}return r},[t]),o=AA.useMemo(()=>Array.from(i.keys()),[i]),n=A?i.get(A):null,s=AA.useMemo(()=>{if(!n)return{instance:null,error:null,classFound:!1};const r=OHA[n.solverName];if(!r)return{instance:null,error:`Solver class "${n.solverName}" not found in SOLVERS registry. Available: ${Object.keys(OHA).join(", ")}`,classFound:!1};try{const a=n.solverParams,g=a?.input!==void 0?a.input:a;return{instance:new r(g),error:null,classFound:!0}}catch(a){const g=a instanceof Error?a.message:String(a);return console.error("Failed to reconstruct solver:",a),{instance:null,error:`Failed to instantiate solver: ${g}`,classFound:!0}}},[n]);return t.length===0?V.jsx("div",{className:"rf-p-4",children:V.jsx("div",{className:"rf-bg-gray-50 rf-rounded-md rf-border rf-border-gray-200",children:V.jsxs("div",{className:"rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800 rf-mb-3",children:"No Solvers Detected"}),V.jsx("p",{className:"rf-text-sm rf-text-gray-600",children:"Solvers will appear here when the circuit runs. Solvers are used for tasks like component packing and autorouting."})]})})}):V.jsxs("div",{className:"rf-flex rf-h-full rf-overflow-hidden",children:[V.jsxs("div",{className:"rf-w-64 rf-border-r rf-border-gray-200 rf-overflow-y-auto rf-flex-shrink-0",children:[V.jsxs("div",{className:"rf-text-xs rf-font-semibold rf-text-gray-500 rf-px-3 rf-py-2 rf-bg-gray-50 rf-border-b rf-border-gray-200",children:[o.length," ",o.length===1?"Solver":"Solvers"]}),o.map(r=>{const a=i.get(r),g=A===r;return V.jsx("div",{className:`rf-px-3 rf-py-2 rf-cursor-pointer rf-border-b rf-border-gray-100 ${g?"rf-bg-blue-50 rf-border-l-2 rf-border-l-blue-500":"hover:rf-bg-gray-50"}`,onClick:()=>e(r),children:(()=>{const I=pHt(a.solverName);return V.jsxs("div",{className:"rf-flex rf-items-center rf-gap-2",children:[V.jsx(I,{className:"rf-w-4 rf-h-4 rf-text-blue-500 rf-flex-shrink-0"}),V.jsxs("div",{className:"rf-flex-1 rf-min-w-0",children:[V.jsx("div",{className:"rf-text-sm rf-font-medium rf-text-gray-800 rf-truncate",children:a.componentName}),V.jsx("div",{className:"rf-text-xs rf-text-gray-500 rf-truncate",children:a.solverName})]})]})})()},r)})]}),V.jsx("div",{className:"rf-flex-1 rf-overflow-hidden",children:n?s.instance?V.jsx(cS,{fallback:V.jsx("div",{className:"rf-p-4",children:V.jsxs("div",{className:"rf-bg-red-50 rf-rounded-md rf-border rf-border-red-200 rf-p-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-red-800 rf-mb-2",children:"Error Loading Solver Debugger"}),V.jsxs("p",{className:"rf-text-sm rf-text-red-600",children:["Failed to render the solver debugger for"," ",n.solverName]})]})}),children:V.jsx(uHt,{solver:s.instance})}):V.jsxs("div",{className:"rf-p-4",children:[V.jsxs("div",{className:"rf-mb-4",children:[V.jsx("h3",{className:"rf-text-lg rf-font-semibold rf-text-gray-800",children:n.solverName}),V.jsxs("p",{className:"rf-text-sm rf-text-gray-500",children:["Component: ",n.componentName]})]}),s.error&&V.jsx("div",{className:`rf-rounded-md rf-border rf-p-4 rf-mb-4 ${s.classFound?"rf-bg-red-50 rf-border-red-200":"rf-bg-yellow-50 rf-border-yellow-200"}`,children:V.jsx("p",{className:`rf-text-sm ${s.classFound?"rf-text-red-700":"rf-text-yellow-700"}`,children:s.error})}),V.jsxs("div",{className:"rf-border rf-border-gray-200 rf-rounded-md rf-overflow-hidden",children:[V.jsx("div",{className:"rf-px-3 rf-py-2 rf-bg-gray-50",children:V.jsx("span",{className:"rf-text-sm rf-font-medium rf-text-gray-700",children:"Solver Parameters"})}),V.jsx("div",{className:"rf-p-3 rf-bg-white rf-border-t rf-border-gray-200",children:V.jsx("pre",{className:"rf-text-xs rf-font-mono rf-text-gray-600 rf-whitespace-pre-wrap rf-overflow-x-auto",children:JSON.stringify(n.solverParams,null,2)})})]})]}):V.jsx("div",{className:"rf-flex rf-items-center rf-justify-center rf-h-full",children:V.jsx("p",{className:"rf-text-sm rf-text-gray-500",children:"Select a solver from the list to view details"})})})]})},fie=({errorMessage:t,errorStack:A,circuitJsonErrors:e})=>{AA.useEffect(()=>{if(t){const i=new Error(t);A&&(i.stack=A);try{OJ.captureException(i)}catch{}}},[t,A]),AA.useEffect(()=>{if(e&&e.length>0)for(const i of e){const o=new Error(i.message||"Circuit JSON Error");i.stack&&(o.stack=i.stack);try{OJ.captureException(o,{error_type:i.type})}catch{}}},[e])},yie="0.0.1421",yHt={version:yie},bEA={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},xEA=new Map,CW=t=>{const A=xEA.get(t);return A?Object.fromEntries(Object.entries(A.stores).map(([e,i])=>[e,i.getState()])):{}},mHt=(t,A,e)=>{if(t===void 0)return{type:"untracked",connection:A.connect(e)};const i=xEA.get(e.name);if(i)return{type:"tracked",store:t,...i};const o={connection:A.connect(e),stores:{}};return xEA.set(e.name,o),{type:"tracked",store:t,...o}},mie=(t,A={})=>(e,i,o)=>{const{enabled:n,anonymousActionType:s,store:r,...a}=A;let g;try{g=(n??(bEA?"production":void 0)!=="production")&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!g)return(bEA?"production":void 0)!=="production"&&n&&console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"),t(e,i,o);const{connection:I,...c}=mHt(r,g,a);let B=!0;o.setState=(Q,E,h)=>{const u=e(Q,E);if(!B)return u;const d=h===void 0?{type:s||"anonymous"}:typeof h=="string"?{type:h}:h;return r===void 0?(I?.send(d,i()),u):(I?.send({...d,type:`${r}/${d.type}`},{...CW(a.name),[r]:o.getState()}),u)};const C=(...Q)=>{const E=B;B=!1,e(...Q),B=E},l=t(o.setState,i,o);if(c.type==="untracked"?I?.init(l):(c.stores[c.store]=o,I?.init(Object.fromEntries(Object.entries(c.stores).map(([Q,E])=>[Q,Q===c.store?l:E.getState()])))),o.dispatchFromDevtools&&typeof o.dispatch=="function"){let Q=!1;const E=o.dispatch;o.dispatch=(...h)=>{(bEA?"production":void 0)!=="production"&&h[0].type==="__setState"&&!Q&&(console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'),Q=!0),E(...h)}}return I.subscribe(Q=>{var E;switch(Q.type){case"ACTION":if(typeof Q.payload!="string"){console.error("[zustand devtools middleware] Unsupported action format");return}return kEA(Q.payload,h=>{if(h.type==="__setState"){if(r===void 0){C(h.state);return}Object.keys(h.state).length!==1&&console.error(`
|
|
5602
5602
|
[zustand devtools middleware] Unsupported __setState action format.
|
|
5603
5603
|
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
5604
5604
|
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|